Merge branch 'xcalloc-fix' into master

This commit is contained in:
Daniel Eklöf 2020-08-26 18:56:12 +02:00
commit 32639e442f
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -1,3 +1,4 @@
#include <assert.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
@ -36,10 +37,8 @@ xmalloc(size_t size)
void *
xcalloc(size_t nmemb, size_t size)
{
if (unlikely(nmemb == 0 || size == 0)) {
size = 1;
}
return check_alloc(calloc(nmemb, size));
assert(size != 0);
return check_alloc(calloc(likely(nmemb) ? nmemb : 1, size));
}
void *