From b2dc086600f64d5a2db179fb6bed79a0a78228e4 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 30 Sep 2010 01:27:38 -0400 Subject: mtd-utils: new memory wrappers The mkfs.jffs2 program has local wrappers for memory related functions that are useful beyond mkfs.jffs2, so break them out into a common header. Signed-off-by: Mike Frysinger Signed-off-by: Artem Bityutskiy --- mkfs.jffs2.c | 41 ----------------------------------------- 1 file changed, 41 deletions(-) (limited to 'mkfs.jffs2.c') diff --git a/mkfs.jffs2.c b/mkfs.jffs2.c index 1abe09c..1ea3598 100644 --- a/mkfs.jffs2.c +++ b/mkfs.jffs2.c @@ -110,7 +110,6 @@ static int squash_uids = 0; static int squash_perms = 0; static int fake_times = 0; int target_endian = __BYTE_ORDER; -static const char *const memory_exhausted = "memory exhausted"; uint32_t find_hardlink(struct filesystem_entry *e) { @@ -197,46 +196,6 @@ static void perror_msg_and_die(const char *s, ...) exit(EXIT_FAILURE); } -#ifndef DMALLOC -extern void *xmalloc(size_t size) -{ - void *ptr = malloc(size); - - if (ptr == NULL && size != 0) - error_msg_and_die(memory_exhausted); - return ptr; -} - -extern void *xcalloc(size_t nmemb, size_t size) -{ - void *ptr = calloc(nmemb, size); - - if (ptr == NULL && nmemb != 0 && size != 0) - error_msg_and_die(memory_exhausted); - return ptr; -} - -extern void *xrealloc(void *ptr, size_t size) -{ - ptr = realloc(ptr, size); - if (ptr == NULL && size != 0) - error_msg_and_die(memory_exhausted); - return ptr; -} - -extern char *xstrdup(const char *s) -{ - char *t; - - if (s == NULL) - return NULL; - t = strdup(s); - if (t == NULL) - error_msg_and_die(memory_exhausted); - return t; -} -#endif - extern char *xreadlink(const char *path) { static const int GROWBY = 80; /* how large we will grow strings by */ -- cgit v1.2.3