123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- static const char rcsid[] = "$Id: util.c,v 1.1 2002/03/24 17:27:12 chris Exp $";
- #include <sys/types.h>
- #include <errno.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <unistd.h>
- #include "iftop.h"
- void *xmalloc(size_t n) {
- void *v;
- v = malloc(n);
- if (!v) abort();
- return v;
- }
- void *xcalloc(size_t n, size_t m) {
- void *v;
- v = calloc(n, m);
- if (!v) abort();
- return v;
- }
- void *xrealloc(void *w, size_t n) {
- void *v;
- v = realloc(w, n);
- if (n != 0 && !v) abort();
- return v;
- }
- char *xstrdup(const char *s) {
- char *t;
- t = strdup(s);
- if (!t) abort();
- return t;
- }
- void xfree(void *v) {
- if (v) free(v);
- }
|