#ifndef _UTIL_H1#define _UTIL_H23/*4* Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc.5*6* This program is free software; you can redistribute it and/or7* modify it under the terms of the GNU General Public License as8* published by the Free Software Foundation; either version 2 of the9* License, or (at your option) any later version.10*11* This program is distributed in the hope that it will be useful,12* but WITHOUT ANY WARRANTY; without even the implied warranty of13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU14* General Public License for more details.15*16* You should have received a copy of the GNU General Public License17* along with this program; if not, write to the Free Software18* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-130719* USA20*/2122static inline void __attribute__((noreturn)) die(char * str, ...)23{24va_list ap;2526va_start(ap, str);27fprintf(stderr, "FATAL ERROR: ");28vfprintf(stderr, str, ap);29exit(1);30}3132static inline void *xmalloc(size_t len)33{34void *new = malloc(len);3536if (!new)37die("malloc() failed\n");3839return new;40}4142static inline void *xrealloc(void *p, size_t len)43{44void *new = realloc(p, len);4546if (!new)47die("realloc() failed (len=%d)\n", len);4849return new;50}5152extern char *xstrdup(const char *s);53extern char *join_path(const char *path, const char *name);5455#endif /* _UTIL_H */565758