diff options
author | Ludovic Courtès <ludo@gnu.org> | 2020-05-07 18:41:10 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2020-05-07 23:52:25 +0200 |
commit | 14928af2af501516aba13d569eae0853e769fb91 (patch) | |
tree | 3829b7d086c5f0f4f100707d532de0722615f7fe /gnu/packages/aux-files | |
parent | 4a53c19a325e7192c5aa6b0b34daf660ea615e17 (diff) | |
download | guix-14928af2af501516aba13d569eae0853e769fb91.tar.gz |
pack: Add 'xmalloc' in wrapper.
* gnu/packages/aux-files/run-in-namespace.c (xmalloc): New function. (concat): Use it.
Diffstat (limited to 'gnu/packages/aux-files')
-rw-r--r-- | gnu/packages/aux-files/run-in-namespace.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/gnu/packages/aux-files/run-in-namespace.c b/gnu/packages/aux-files/run-in-namespace.c index 37c493eeeb..501f096dc6 100644 --- a/gnu/packages/aux-files/run-in-namespace.c +++ b/gnu/packages/aux-files/run-in-namespace.c @@ -42,13 +42,21 @@ #include <dirent.h> #include <sys/syscall.h> +/* Like 'malloc', but abort if 'malloc' returns NULL. */ +static void * +xmalloc (size_t size) +{ + void *result = malloc (size); + assert (result != NULL); + return result; +} + /* Concatenate DIRECTORY, a slash, and FILE. Return the result, which the caller must eventually free. */ static char * concat (const char *directory, const char *file) { - char *result = malloc (strlen (directory) + 2 + strlen (file)); - assert (result != NULL); + char *result = xmalloc (strlen (directory) + 2 + strlen (file)); strcpy (result, directory); strcat (result, "/"); |