mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 15:36:20 -05:00
pack: Add 'xmalloc' in wrapper.
* gnu/packages/aux-files/run-in-namespace.c (xmalloc): New function. (concat): Use it.
This commit is contained in:
parent
4a53c19a32
commit
14928af2af
1 changed files with 10 additions and 2 deletions
|
@ -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, "/");
|
||||
|
|
Loading…
Reference in a new issue