diff options
author | Robert Buchholz <rbu@goodpoint.de> | 2012-07-16 23:56:54 +0200 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2012-09-10 09:23:59 +0200 |
commit | 1cc101f3f873fac4110aeece95bfe391fc8680c2 (patch) | |
tree | dc5c355cd1b00cc7c729c2986f7f863f23f320fe /util.c | |
parent | mapfile: fix mapfile rebuild for containers (diff) | |
download | mdadm-1cc101f3f873fac4110aeece95bfe391fc8680c2.tar.xz mdadm-1cc101f3f873fac4110aeece95bfe391fc8680c2.zip |
Move xmalloc et al into their own file
This avoid code duplication for utilities that do not link to
util.c and everything that comes with it, such as test_restripe and
raid6check
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 40 |
1 files changed, 0 insertions, 40 deletions
@@ -1807,43 +1807,3 @@ struct mdinfo *container_choose_spares(struct supertype *st, } return disks; } - -void *xmalloc(size_t len) -{ - void *rv = malloc(len); - char *msg; - if (rv) - return rv; - msg = Name ": memory allocation failure - aborting\n"; - exit(4+!!write(2, msg, strlen(msg))); -} - -void *xrealloc(void *ptr, size_t len) -{ - void *rv = realloc(ptr, len); - char *msg; - if (rv) - return rv; - msg = Name ": memory allocation failure - aborting\n"; - exit(4+!!write(2, msg, strlen(msg))); -} - -void *xcalloc(size_t num, size_t size) -{ - void *rv = calloc(num, size); - char *msg; - if (rv) - return rv; - msg = Name ": memory allocation failure - aborting\n"; - exit(4+!!write(2, msg, strlen(msg))); -} - -char *xstrdup(const char *str) -{ - char *rv = strdup(str); - char *msg; - if (rv) - return rv; - msg = Name ": memory allocation failure - aborting\n"; - exit(4+!!write(2, msg, strlen(msg))); -} |