2 * This file is part of libFirm.
3 * Copyright (C) 2012 University of Karlsruhe.
8 * @brief implementation of xmalloc & friends
9 * @author Markus Armbruster
12 /* @@@ ToDo: replace this file with the one from liberty.
13 [reimplement xstrdup, ... ] */
23 static NORETURN xnomem(void)
25 /* Do not use panic() here, because it might try to allocate memory! */
26 fputs("out of memory", stderr);
30 void *xmalloc(size_t size)
32 void *res = malloc(size);
38 void *xrealloc(void *ptr, size_t size)
40 /* ANSI blesses realloc (0, x) but SunOS chokes on it */
41 void *res = ptr ? realloc (ptr, size) : malloc (size);
47 char *xstrdup(const char *str)
49 size_t len = strlen (str) + 1;
50 return (char*) memcpy(xmalloc(len), str, len);