#ifdef HAVE_CONFIG_H # include "config.h" #endif #ifdef HAVE_STDLIB_H # include #endif #ifdef HAVE_STRING_H # include #endif #include "error.h" #include "xfunctions.h" void *xmalloc(size_t size, const char *message){ void *mem; if((mem = malloc(size)) == NULL) AnugaVis_SetError("%s: Failed to malloc %d bytes", message, size); return mem; } #ifndef HAVE_STRDUP char *strdup(const char *s){ char *str; if((str = malloc(strlen(s) + 1)) != NULL) strcpy(str, s); return str; } #endif char *xstrdup(const char *s, const char *message){ char *str; if((str = strdup(s)) == NULL) AnugaVis_SetError("%s: Failed to strdup \"%s\"", message, s); return str; }