Moved some code and add a coupld #defines to support use of dmalloc.
authorEric Andersen <andersen@codepoet.org>
Wed, 19 Jul 2000 17:35:54 +0000 (17:35 -0000)
committerEric Andersen <andersen@codepoet.org>
Wed, 19 Jul 2000 17:35:54 +0000 (17:35 -0000)
 -Erik

insmod.c
internal.h
modutils/insmod.c
utility.c

index 9daedf9..cd75e24 100644 (file)
--- a/insmod.c
+++ b/insmod.c
@@ -70,7 +70,7 @@
 #ifndef MODUTILS_MODULE_H
 #define MODUTILS_MODULE_H 1
 
-#ident "$Id: insmod.c,v 1.18 2000/07/16 20:57:15 kraai Exp $"
+#ident "$Id: insmod.c,v 1.19 2000/07/19 17:35:54 andersen Exp $"
 
 /* This file contains the structures used by the 2.0 and 2.1 kernels.
    We do not use the kernel headers directly because we do not wish
@@ -276,7 +276,7 @@ int delete_module(const char *);
 #ifndef MODUTILS_OBJ_H
 #define MODUTILS_OBJ_H 1
 
-#ident "$Id: insmod.c,v 1.18 2000/07/16 20:57:15 kraai Exp $"
+#ident "$Id: insmod.c,v 1.19 2000/07/19 17:35:54 andersen Exp $"
 
 /* The relocatable object is manipulated using elfin types.  */
 
@@ -563,16 +563,6 @@ static char m_fullName[BUFSIZ + 1] = "\0";
 
 /*======================================================================*/
 
-void *xrealloc(void *old, size_t size)
-{
-       void *ptr = realloc(old, size);
-       if (!ptr) {
-               perror("Out of memory");
-               exit(1);
-       }
-       return ptr;
-}
-
 
 static int findNamedModule(const char *fileName, struct stat *statbuf,
                                                   void *userDate)
index 5cf72d6..52419e3 100644 (file)
 
 #include "busybox.def.h"
 
+#ifdef DMALLOC
+#include "dmalloc.h"
+#endif
+
 #include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
@@ -360,8 +364,11 @@ extern char process_escape_sequence(char **ptr);
 extern char *get_last_path_component(char *path);
 extern void xregcomp(regex_t *preg, const char *regex, int cflags);
 
+#ifndef DMALLOC 
 extern void *xmalloc (size_t size);
+extern void *xrealloc(void *old, size_t size)
 extern char *xstrdup (const char *s);
+#endif
 extern char *xstrndup (const char *s, int n);
 
 
index 9daedf9..cd75e24 100644 (file)
@@ -70,7 +70,7 @@
 #ifndef MODUTILS_MODULE_H
 #define MODUTILS_MODULE_H 1
 
-#ident "$Id: insmod.c,v 1.18 2000/07/16 20:57:15 kraai Exp $"
+#ident "$Id: insmod.c,v 1.19 2000/07/19 17:35:54 andersen Exp $"
 
 /* This file contains the structures used by the 2.0 and 2.1 kernels.
    We do not use the kernel headers directly because we do not wish
@@ -276,7 +276,7 @@ int delete_module(const char *);
 #ifndef MODUTILS_OBJ_H
 #define MODUTILS_OBJ_H 1
 
-#ident "$Id: insmod.c,v 1.18 2000/07/16 20:57:15 kraai Exp $"
+#ident "$Id: insmod.c,v 1.19 2000/07/19 17:35:54 andersen Exp $"
 
 /* The relocatable object is manipulated using elfin types.  */
 
@@ -563,16 +563,6 @@ static char m_fullName[BUFSIZ + 1] = "\0";
 
 /*======================================================================*/
 
-void *xrealloc(void *old, size_t size)
-{
-       void *ptr = realloc(old, size);
-       if (!ptr) {
-               perror("Out of memory");
-               exit(1);
-       }
-       return ptr;
-}
-
 
 static int findNamedModule(const char *fileName, struct stat *statbuf,
                                                   void *userDate)
index 18d3c14..50f497f 100644 (file)
--- a/utility.c
+++ b/utility.c
@@ -1454,17 +1454,28 @@ extern pid_t* findPidByName( char* pidName)
 #endif                                                 /* BB_FEATURE_USE_DEVPS_PATCH */
 #endif                                                 /* BB_KILLALL || ( BB_FEATURE_LINUXRC && ( BB_HALT || BB_REBOOT || BB_POWEROFF )) */
 
+#ifndef DMALLOC
 /* this should really be farmed out to libbusybox.a */
 extern void *xmalloc(size_t size)
 {
-       void *cp = malloc(size);
+       void *ptr = malloc(size);
 
-       if (cp == NULL)
+       if (!ptr)
                fatalError(memory_exhausted);
-       return cp;
+       return ptr;
 }
 
+void *xrealloc(void *old, size_t size)
+{
+       void *ptr = realloc(old, size);
+       if (!ptr)
+               fatalError(memory_exhausted);
+       return ptr;
+}
+#endif
+
 #if defined BB_FEATURE_NFSMOUNT
+# ifndef DMALLOC
 extern char * xstrdup (const char *s) {
        char *t;
 
@@ -1478,6 +1489,7 @@ extern char * xstrdup (const char *s) {
 
        return t;
 }
+# endif
 
 extern char * xstrndup (const char *s, int n) {
        char *t;