blob: 63095fb038a26a42cbc54eb510697783fa471417 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#include <assert.h>
#include <errno.h>
#include <stdint.h>
#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 (unlikely(size > SIZE_MAX / nmemb)) {
errno = ENOMEM;
err("%s:", __func__);
}
if (unlikely((ptr = realloc(ptr, nmemb * size)) == NULL))
err("%s:", __func__);
return ptr;
}
|