diff options
Diffstat (limited to 'libexec/rtld-elf/malloc.c')
-rw-r--r-- | libexec/rtld-elf/malloc.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libexec/rtld-elf/malloc.c b/libexec/rtld-elf/malloc.c index 2fe69a7..3da5bee 100644 --- a/libexec/rtld-elf/malloc.c +++ b/libexec/rtld-elf/malloc.c @@ -236,6 +236,22 @@ malloc(nbytes) return ((char *)(op + 1)); } +void * +calloc(size_t num, size_t size) +{ + void *ret; + + if (size != 0 && (num * size) / size != num) { + /* size_t overflow. */ + return (NULL); + } + + if ((ret = malloc(num * size)) != NULL) + memset(ret, 0, num * size); + + return (ret); +} + /* * Allocate more memory to the indicated bucket. */ |