aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libbb.h1
-rw-r--r--libbb/xfuncs.c9
2 files changed, 10 insertions, 0 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 461c28fcb..ca3afea98 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -183,6 +183,7 @@ void run_applet_by_name(const char *name, int argc, char **argv);
183 * to have the prototypes here unconditionally. */ 183 * to have the prototypes here unconditionally. */
184extern void *xmalloc(size_t size); 184extern void *xmalloc(size_t size);
185extern void *xrealloc(void *old, size_t size); 185extern void *xrealloc(void *old, size_t size);
186extern void *xzalloc(size_t size);
186extern void *xcalloc(size_t nmemb, size_t size); 187extern void *xcalloc(size_t nmemb, size_t size);
187 188
188extern char *bb_xstrdup (const char *s); 189extern char *bb_xstrdup (const char *s);
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index fa6aa0f9f..d3c9e41e1 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -37,6 +37,15 @@ void *xrealloc(void *ptr, size_t size)
37} 37}
38#endif 38#endif
39 39
40#ifdef L_xzalloc
41void *xzalloc(size_t size)
42{
43 void *ptr = xmalloc(size);
44 memset(ptr, 0, size);
45 return ptr;
46}
47#endif
48
40#ifdef L_xcalloc 49#ifdef L_xcalloc
41void *xcalloc(size_t nmemb, size_t size) 50void *xcalloc(size_t nmemb, size_t size)
42{ 51{