pack: Add 'xmalloc' in wrapper.

* gnu/packages/aux-files/run-in-namespace.c (xmalloc): New function.
(concat): Use it.
This commit is contained in:
Ludovic Courtès 2020-05-07 18:41:10 +02:00
parent 4a53c19a32
commit 14928af2af
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -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, "/");