Updates with latest tommyds library.

This commit is contained in:
Andrea Mazzoleni 2014-09-26 23:50:01 +02:00
parent eeea58b42a
commit d84babb6bd
16 changed files with 189 additions and 118 deletions

View file

@ -1505,9 +1505,27 @@ void* malloc_nofail(size_t size)
return ptr;
}
void* cmalloc_nofail(size_t count, size_t size)
void* calloc_nofail(size_t count, size_t size)
{
return malloc_nofail(count * size);
void* ptr;
size *= count;
/* see the note in malloc_nofail() of why we don't use calloc() */
ptr = malloc(size);
if (!ptr) {
/* LCOV_EXCL_START */
malloc_fail(size);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
memset(ptr, 0, size);
mcounter += size;
return ptr;
}
char* strdup_nofail(const char* str)

View file

@ -468,7 +468,7 @@ void* malloc_nofail(size_t size);
* Safe cmalloc.
* If no memory is available, it aborts.
*/
void* cmalloc_nofail(size_t count, size_t size);
void* calloc_nofail(size_t count, size_t size);
/**
* Safe aligned malloc.