summaryrefslogtreecommitdiff
path: root/nasmlib.h
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-09-25 14:27:34 -0700
committerH. Peter Anvin <hpa@zytor.com>2007-09-25 14:27:34 -0700
commitcfdf646e9a818067887cdc9c01ade5b79f699190 (patch)
tree9b72a37341ccc6718cf23d6a3527ddb22d9a6d9e /nasmlib.h
parent3e1aaa9dd0cc48e390deb1c3f356b3ad1781af67 (diff)
downloadnasm-cfdf646e9a818067887cdc9c01ade5b79f699190.tar.gz
nasm-cfdf646e9a818067887cdc9c01ade5b79f699190.tar.bz2
nasm-cfdf646e9a818067887cdc9c01ade5b79f699190.zip
Add nasm_zalloc() to nasmlib.c
Add nasm_zalloc(), a wrapper around calloc(), to allocate zero-initialized memory. For large allocations, this is often far more efficient than allocating and zeroing, since the operating system tends to keep a pool of zero pages around.
Diffstat (limited to 'nasmlib.h')
-rw-r--r--nasmlib.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/nasmlib.h b/nasmlib.h
index 4334209..a2544fc 100644
--- a/nasmlib.h
+++ b/nasmlib.h
@@ -74,17 +74,20 @@ typedef void (*efunc) (int severity, const char *fmt, ...);
void nasm_set_malloc_error(efunc);
#ifndef LOGALLOC
void *nasm_malloc(size_t);
+void *nasm_zalloc(size_t);
void *nasm_realloc(void *, size_t);
void nasm_free(void *);
char *nasm_strdup(const char *);
char *nasm_strndup(char *, size_t);
#else
void *nasm_malloc_log(char *, int, size_t);
+void *nasm_zalloc_log(char *, int, size_t);
void *nasm_realloc_log(char *, int, void *, size_t);
void nasm_free_log(char *, int, void *);
char *nasm_strdup_log(char *, int, const char *);
char *nasm_strndup_log(char *, int, char *, size_t);
#define nasm_malloc(x) nasm_malloc_log(__FILE__,__LINE__,x)
+#define nasm_zalloc(x) nasm_malloc_log(__FILE__,__LINE__,x)
#define nasm_realloc(x,y) nasm_realloc_log(__FILE__,__LINE__,x,y)
#define nasm_free(x) nasm_free_log(__FILE__,__LINE__,x)
#define nasm_strdup(x) nasm_strdup_log(__FILE__,__LINE__,x)