summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authorjasone <jasone@FreeBSD.org>2006-01-12 07:28:21 +0000
committerjasone <jasone@FreeBSD.org>2006-01-12 07:28:21 +0000
commit3668a2e4940ebe0e7c33729ad375a9a7b0c6ceb1 (patch)
tree25770955017440672d2cba68e6d8c382b53d9f75 /libexec
parent40e5b400fdbcc7db744cb07d18d2c5dcfdb6fd18 (diff)
downloadFreeBSD-src-3668a2e4940ebe0e7c33729ad375a9a7b0c6ceb1.zip
FreeBSD-src-3668a2e4940ebe0e7c33729ad375a9a7b0c6ceb1.tar.gz
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)
Diffstat (limited to 'libexec')
-rw-r--r--libexec/rtld-elf/malloc.c16
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.
*/
OpenPOWER on IntegriCloud