diff options
author | Jason Evans <jasone@FreeBSD.org> | 2006-01-12 07:28:21 +0000 |
---|---|---|
committer | Jason Evans <jasone@FreeBSD.org> | 2006-01-12 07:28:21 +0000 |
commit | 52828c0e9cfdf1681a8c16cf313294ad1413ac25 (patch) | |
tree | 25770955017440672d2cba68e6d8c382b53d9f75 /libexec/rtld-elf/malloc.c | |
parent | 0b61bced98b63acd9e76e015a0b46bce86a0bdd4 (diff) | |
download | src-52828c0e9cfdf1681a8c16cf313294ad1413ac25.tar.gz src-52828c0e9cfdf1681a8c16cf313294ad1413ac25.zip |
In preparation for a new malloc implementation:
* Add posix_memalign().
* Move calloc() from calloc.c to malloc.c. Add a calloc() implementation in
rtld-elf in order to make the loader happy (even though calloc() isn't
used in rtld-elf).
* Add _malloc_prefork() and _malloc_postfork(), and use them instead of
directly manipulating __malloc_lock.
Approved by: phk, markm (mentor)
Notes
Notes:
svn path=/head/; revision=154248
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 2fe69a78b22e..3da5bee3b7fa 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. */ |