Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
28 lines (18 sloc) 677 Bytes
/*
Definitions for error-checking memory allocator
*/
#ifndef ALLOC_H
#define ALLOC_H
#ifdef SMARTALLOC
extern void *sm_xmalloc(char *fname, int lineno, size_t size);
extern void *sm_xrealloc(char *fname, int lineno, void *ptr, size_t size);
extern char *sm_xstrdup(char *fname, int lineno, const char *s);
#define xmalloc(x) sm_xmalloc( __FILE__, __LINE__, (x))
#define xrealloc(p,x) sm_xrealloc(__FILE__, __LINE__, (p), (x))
#define xstrdup(s) sm_xstrdup( __FILE__, __LINE__, (s))
#else
extern void *xmalloc(size_t size);
extern void *xrealloc(void *ptr, size_t size);
extern char *xstrdup(const char *s);
#endif
#endif /* ALLOC_H not defined */