diff options
author | Slávek Banko <[email protected]> | 2015-10-21 20:24:02 +0200 |
---|---|---|
committer | Slávek Banko <[email protected]> | 2015-10-21 20:24:02 +0200 |
commit | d057953830e148631c371b140d983d7a25c064da (patch) | |
tree | 66d0365c5b07581a2598e0ded198f38b51c59184 /src/xmalloc.h | |
parent | bb1740cd7327374a1124cb2931ba77ea59c90867 (diff) | |
download | smartcardauth-d057953830e148631c371b140d983d7a25c064da.tar.gz smartcardauth-d057953830e148631c371b140d983d7a25c064da.zip |
This resolves Bug 2434
Signed-off-by: Slávek Banko <[email protected]>
Diffstat (limited to 'src/xmalloc.h')
-rw-r--r-- | src/xmalloc.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/xmalloc.h b/src/xmalloc.h new file mode 100644 index 0000000..6f64ddc --- /dev/null +++ b/src/xmalloc.h @@ -0,0 +1,28 @@ +/* $Id: xmalloc.h $ + * + * malloc routines with failure handling. + * + */ + +#if !defined(_XMALLOC_H) +#define _XMALLOC_H + +/* The functions are actually macros so that we can pick up the file and line + number information for debugging error messages without the user having to + pass those in every time. */ +#define xcalloc(n, size) x_calloc((n), (size), __FILE__, __LINE__) +#define xmalloc(size) x_malloc((size), __FILE__, __LINE__) +#define xrealloc(p, size) x_realloc((p), (size), __FILE__, __LINE__) +#define xstrdup(p) x_strdup((p), __FILE__, __LINE__) +#define xstrndup(p, size) x_strndup((p), (size), __FILE__, __LINE__) + +/* + * Prototypes of functions + */ +void* x_malloc(size_t size, const char *file, int line); +void* x_calloc(size_t n, size_t size, const char *file, int line); +void* x_realloc(void *p, size_t size, const char *file, int line); +char* x_strdup(const char *s, const char *file, int line); +char* x_strndup(const char *s, size_t size, const char *file, int line); + +#endif /* _XMALLOC_H */ |