From 14928af2af501516aba13d569eae0853e769fb91 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 7 May 2020 18:41:10 +0200 Subject: pack: Add 'xmalloc' in wrapper. * gnu/packages/aux-files/run-in-namespace.c (xmalloc): New function. (concat): Use it. --- gnu/packages/aux-files/run-in-namespace.c | 12 ++++++++++-- 1 file 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 #include +/* 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, "/"); -- cgit v1.2.3