diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-07-19 17:35:54 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-07-19 17:35:54 +0000 |
commit | ae6eae02dd85a196a4545376a50166aede8ce7c1 (patch) | |
tree | c3dbc22408e4323f916fb1f1171f7aa73fa2aecc | |
parent | 52d6fa3bb335fcfefc2b205e7ba509fc4b284793 (diff) | |
download | busybox-w32-ae6eae02dd85a196a4545376a50166aede8ce7c1.tar.gz busybox-w32-ae6eae02dd85a196a4545376a50166aede8ce7c1.tar.bz2 busybox-w32-ae6eae02dd85a196a4545376a50166aede8ce7c1.zip |
Moved some code and add a coupld #defines to support use of dmalloc.
-Erik
-rw-r--r-- | insmod.c | 14 | ||||
-rw-r--r-- | internal.h | 7 | ||||
-rw-r--r-- | modutils/insmod.c | 14 | ||||
-rw-r--r-- | utility.c | 18 |
4 files changed, 26 insertions, 27 deletions
@@ -70,7 +70,7 @@ | |||
70 | #ifndef MODUTILS_MODULE_H | 70 | #ifndef MODUTILS_MODULE_H |
71 | #define MODUTILS_MODULE_H 1 | 71 | #define MODUTILS_MODULE_H 1 |
72 | 72 | ||
73 | #ident "$Id: insmod.c,v 1.18 2000/07/16 20:57:15 kraai Exp $" | 73 | #ident "$Id: insmod.c,v 1.19 2000/07/19 17:35:54 andersen Exp $" |
74 | 74 | ||
75 | /* This file contains the structures used by the 2.0 and 2.1 kernels. | 75 | /* This file contains the structures used by the 2.0 and 2.1 kernels. |
76 | We do not use the kernel headers directly because we do not wish | 76 | We do not use the kernel headers directly because we do not wish |
@@ -276,7 +276,7 @@ int delete_module(const char *); | |||
276 | #ifndef MODUTILS_OBJ_H | 276 | #ifndef MODUTILS_OBJ_H |
277 | #define MODUTILS_OBJ_H 1 | 277 | #define MODUTILS_OBJ_H 1 |
278 | 278 | ||
279 | #ident "$Id: insmod.c,v 1.18 2000/07/16 20:57:15 kraai Exp $" | 279 | #ident "$Id: insmod.c,v 1.19 2000/07/19 17:35:54 andersen Exp $" |
280 | 280 | ||
281 | /* The relocatable object is manipulated using elfin types. */ | 281 | /* The relocatable object is manipulated using elfin types. */ |
282 | 282 | ||
@@ -563,16 +563,6 @@ static char m_fullName[BUFSIZ + 1] = "\0"; | |||
563 | 563 | ||
564 | /*======================================================================*/ | 564 | /*======================================================================*/ |
565 | 565 | ||
566 | void *xrealloc(void *old, size_t size) | ||
567 | { | ||
568 | void *ptr = realloc(old, size); | ||
569 | if (!ptr) { | ||
570 | perror("Out of memory"); | ||
571 | exit(1); | ||
572 | } | ||
573 | return ptr; | ||
574 | } | ||
575 | |||
576 | 566 | ||
577 | static int findNamedModule(const char *fileName, struct stat *statbuf, | 567 | static int findNamedModule(const char *fileName, struct stat *statbuf, |
578 | void *userDate) | 568 | void *userDate) |
diff --git a/internal.h b/internal.h index 5cf72d6d3..52419e34e 100644 --- a/internal.h +++ b/internal.h | |||
@@ -26,6 +26,10 @@ | |||
26 | 26 | ||
27 | #include "busybox.def.h" | 27 | #include "busybox.def.h" |
28 | 28 | ||
29 | #ifdef DMALLOC | ||
30 | #include "dmalloc.h" | ||
31 | #endif | ||
32 | |||
29 | #include <stdlib.h> | 33 | #include <stdlib.h> |
30 | #include <stdarg.h> | 34 | #include <stdarg.h> |
31 | #include <string.h> | 35 | #include <string.h> |
@@ -360,8 +364,11 @@ extern char process_escape_sequence(char **ptr); | |||
360 | extern char *get_last_path_component(char *path); | 364 | extern char *get_last_path_component(char *path); |
361 | extern void xregcomp(regex_t *preg, const char *regex, int cflags); | 365 | extern void xregcomp(regex_t *preg, const char *regex, int cflags); |
362 | 366 | ||
367 | #ifndef DMALLOC | ||
363 | extern void *xmalloc (size_t size); | 368 | extern void *xmalloc (size_t size); |
369 | extern void *xrealloc(void *old, size_t size) | ||
364 | extern char *xstrdup (const char *s); | 370 | extern char *xstrdup (const char *s); |
371 | #endif | ||
365 | extern char *xstrndup (const char *s, int n); | 372 | extern char *xstrndup (const char *s, int n); |
366 | 373 | ||
367 | 374 | ||
diff --git a/modutils/insmod.c b/modutils/insmod.c index 9daedf938..cd75e2416 100644 --- a/modutils/insmod.c +++ b/modutils/insmod.c | |||
@@ -70,7 +70,7 @@ | |||
70 | #ifndef MODUTILS_MODULE_H | 70 | #ifndef MODUTILS_MODULE_H |
71 | #define MODUTILS_MODULE_H 1 | 71 | #define MODUTILS_MODULE_H 1 |
72 | 72 | ||
73 | #ident "$Id: insmod.c,v 1.18 2000/07/16 20:57:15 kraai Exp $" | 73 | #ident "$Id: insmod.c,v 1.19 2000/07/19 17:35:54 andersen Exp $" |
74 | 74 | ||
75 | /* This file contains the structures used by the 2.0 and 2.1 kernels. | 75 | /* This file contains the structures used by the 2.0 and 2.1 kernels. |
76 | We do not use the kernel headers directly because we do not wish | 76 | We do not use the kernel headers directly because we do not wish |
@@ -276,7 +276,7 @@ int delete_module(const char *); | |||
276 | #ifndef MODUTILS_OBJ_H | 276 | #ifndef MODUTILS_OBJ_H |
277 | #define MODUTILS_OBJ_H 1 | 277 | #define MODUTILS_OBJ_H 1 |
278 | 278 | ||
279 | #ident "$Id: insmod.c,v 1.18 2000/07/16 20:57:15 kraai Exp $" | 279 | #ident "$Id: insmod.c,v 1.19 2000/07/19 17:35:54 andersen Exp $" |
280 | 280 | ||
281 | /* The relocatable object is manipulated using elfin types. */ | 281 | /* The relocatable object is manipulated using elfin types. */ |
282 | 282 | ||
@@ -563,16 +563,6 @@ static char m_fullName[BUFSIZ + 1] = "\0"; | |||
563 | 563 | ||
564 | /*======================================================================*/ | 564 | /*======================================================================*/ |
565 | 565 | ||
566 | void *xrealloc(void *old, size_t size) | ||
567 | { | ||
568 | void *ptr = realloc(old, size); | ||
569 | if (!ptr) { | ||
570 | perror("Out of memory"); | ||
571 | exit(1); | ||
572 | } | ||
573 | return ptr; | ||
574 | } | ||
575 | |||
576 | 566 | ||
577 | static int findNamedModule(const char *fileName, struct stat *statbuf, | 567 | static int findNamedModule(const char *fileName, struct stat *statbuf, |
578 | void *userDate) | 568 | void *userDate) |
@@ -1454,17 +1454,28 @@ extern pid_t* findPidByName( char* pidName) | |||
1454 | #endif /* BB_FEATURE_USE_DEVPS_PATCH */ | 1454 | #endif /* BB_FEATURE_USE_DEVPS_PATCH */ |
1455 | #endif /* BB_KILLALL || ( BB_FEATURE_LINUXRC && ( BB_HALT || BB_REBOOT || BB_POWEROFF )) */ | 1455 | #endif /* BB_KILLALL || ( BB_FEATURE_LINUXRC && ( BB_HALT || BB_REBOOT || BB_POWEROFF )) */ |
1456 | 1456 | ||
1457 | #ifndef DMALLOC | ||
1457 | /* this should really be farmed out to libbusybox.a */ | 1458 | /* this should really be farmed out to libbusybox.a */ |
1458 | extern void *xmalloc(size_t size) | 1459 | extern void *xmalloc(size_t size) |
1459 | { | 1460 | { |
1460 | void *cp = malloc(size); | 1461 | void *ptr = malloc(size); |
1461 | 1462 | ||
1462 | if (cp == NULL) | 1463 | if (!ptr) |
1463 | fatalError(memory_exhausted); | 1464 | fatalError(memory_exhausted); |
1464 | return cp; | 1465 | return ptr; |
1465 | } | 1466 | } |
1466 | 1467 | ||
1468 | void *xrealloc(void *old, size_t size) | ||
1469 | { | ||
1470 | void *ptr = realloc(old, size); | ||
1471 | if (!ptr) | ||
1472 | fatalError(memory_exhausted); | ||
1473 | return ptr; | ||
1474 | } | ||
1475 | #endif | ||
1476 | |||
1467 | #if defined BB_FEATURE_NFSMOUNT | 1477 | #if defined BB_FEATURE_NFSMOUNT |
1478 | # ifndef DMALLOC | ||
1468 | extern char * xstrdup (const char *s) { | 1479 | extern char * xstrdup (const char *s) { |
1469 | char *t; | 1480 | char *t; |
1470 | 1481 | ||
@@ -1478,6 +1489,7 @@ extern char * xstrdup (const char *s) { | |||
1478 | 1489 | ||
1479 | return t; | 1490 | return t; |
1480 | } | 1491 | } |
1492 | # endif | ||
1481 | 1493 | ||
1482 | extern char * xstrndup (const char *s, int n) { | 1494 | extern char * xstrndup (const char *s, int n) { |
1483 | char *t; | 1495 | char *t; |