Check malloc return value
This commit is contained in:
parent
12cf6b1f89
commit
a2d2e1de60
@ -126,6 +126,8 @@ static int allocSlab(struct slabDesc **desc, size_t size, size_t sizeSlab, int s
|
||||
((*desc)->slab).freeEl = (char *)(*desc) + sizeof(struct slabDesc);
|
||||
} else {
|
||||
*desc = malloc(sizeof(struct slabDesc));
|
||||
if (*desc == NULL)
|
||||
return -ENOMEM;
|
||||
(*desc)->slab.freeEl = (void *)alloc;
|
||||
}
|
||||
|
||||
@ -174,6 +176,8 @@ static int allocSlabEntry(struct slabEntry **desc, size_t size, size_t sizeSlab,
|
||||
(*desc)->freeEl = (char *)(*desc) + sizeof(struct slabEntry);
|
||||
} else {
|
||||
*desc = malloc(sizeof(struct slabEntry));
|
||||
if (*desc == NULL)
|
||||
return -ENOMEM;
|
||||
(*desc)->freeEl = (void *)alloc;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user