aboutsummaryrefslogtreecommitdiff
path: root/src/alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 8682656..63095fb 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -4,17 +4,18 @@
#include <stdlib.h>
#include "alloc.h"
+#include "common.h"
#include "errors.h"
void *
bufalloc(void *ptr, size_t nmemb, size_t size)
{
assert(nmemb * size != 0);
- if (size > SIZE_MAX / nmemb) {
- errno = EOVERFLOW;
+ if (unlikely(size > SIZE_MAX / nmemb)) {
+ errno = ENOMEM;
err("%s:", __func__);
}
- if ((ptr = realloc(ptr, nmemb * size)) == NULL)
+ if (unlikely((ptr = realloc(ptr, nmemb * size)) == NULL))
err("%s:", __func__);
return ptr;
}