summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnu/packages/aux-files/run-in-namespace.c12
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, "/");