mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Updates with latest tommyds library.
This commit is contained in:
parent
eeea58b42a
commit
d84babb6bd
16 changed files with 189 additions and 118 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue