svn commit: trunk/busybox: include libbb
landley at busybox.net
landley at busybox.net
Fri May 19 20:36:51 UTC 2006
Author: landley
Date: 2006-05-19 13:36:49 -0700 (Fri, 19 May 2006)
New Revision: 15142
Log:
A pending item in my tree I might as well check in: I plan to migrate calloc()
and bb_calloc() calls to bb_xzalloc() which allocates prezeroed memory but
only takes one argument (the size).
Modified:
trunk/busybox/include/libbb.h
trunk/busybox/libbb/xfuncs.c
Changeset:
Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h 2006-05-19 19:29:19 UTC (rev 15141)
+++ trunk/busybox/include/libbb.h 2006-05-19 20:36:49 UTC (rev 15142)
@@ -183,6 +183,7 @@
* to have the prototypes here unconditionally. */
extern void *xmalloc(size_t size);
extern void *xrealloc(void *old, size_t size);
+extern void *xzalloc(size_t size);
extern void *xcalloc(size_t nmemb, size_t size);
extern char *bb_xstrdup (const char *s);
Modified: trunk/busybox/libbb/xfuncs.c
===================================================================
--- trunk/busybox/libbb/xfuncs.c 2006-05-19 19:29:19 UTC (rev 15141)
+++ trunk/busybox/libbb/xfuncs.c 2006-05-19 20:36:49 UTC (rev 15142)
@@ -37,6 +37,15 @@
}
#endif
+#ifdef L_xzalloc
+void *xzalloc(size_t size)
+{
+ void *ptr = xmalloc(size);
+ memset(ptr, 0, size);
+ return ptr;
+}
+#endif
+
#ifdef L_xcalloc
void *xcalloc(size_t nmemb, size_t size)
{
More information about the busybox-cvs
mailing list