diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-06-11 07:46:51 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-06-11 07:46:51 +0200 |
commit | 744ec3c18d6e312d1e2cc281915d251fca49ae55 (patch) | |
tree | 6c16a41a6f8da70da34753c8a7892c55813f5c28 /src/alloc.c | |
parent | d40fe3a6503586eb2ce93311cc4bf23febfbeb83 (diff) |
Add basic LLVM codegen
Diffstat (limited to 'src/alloc.c')
-rw-r--r-- | src/alloc.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/alloc.c b/src/alloc.c new file mode 100644 index 0000000..35b45c0 --- /dev/null +++ b/src/alloc.c @@ -0,0 +1,18 @@ +#include <errno.h> +#include <stdint.h> +#include <stdlib.h> + +#include "alloc.h" +#include "errors.h" + +void * +bufalloc(void *ptr, size_t nmemb, size_t size) +{ + if (size > SIZE_MAX / nmemb) { + errno = EOVERFLOW; + err("%s:", __func__); + } + if ((ptr = realloc(ptr, nmemb * size)) == NULL) + err("%s:", __func__); + return ptr; +} |