Add zalloc

This commit is contained in:
Mathieu Maret 2021-10-04 21:20:16 +02:00
parent 92b4f4af3a
commit 9c36f3afa2
2 changed files with 10 additions and 0 deletions

View File

@ -304,6 +304,15 @@ void *malloc(size_t size)
return ret;
}
void *zalloc(size_t size){
void *alloc = malloc(size);
if (alloc != NULL)
memset(alloc, 0, size);
return alloc;
}
static int freeFromSlab(void *ptr, struct slabEntry *slab)
{
struct slabEntry *slabEntry;

View File

@ -15,6 +15,7 @@ int allocPopulate();
int allocBookSlab(size_t size, size_t sizeSlab, int selfContained);
void *malloc(size_t size);
void *zalloc(size_t size);
void free(void *ptr);
/* Stuct definition shared for test purpose