1 /*
2 * LASH
3 *
4 * Copyright (C) 2002 Robert Ham <rah@bash.sh>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (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 of
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef __LASH_XMALLOC_H__
21 #define __LASH_XMALLOC_H__
22
23 #ifdef LASH_BUILD
24 #define _GNU_SOURCE
25 #include "config.h"
26 #endif /* LASH_BUILD */
27
28 #include <stdlib.h>
29 #include <stdio.h>
30 #include <string.h>
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36
37 #ifdef LASH_DEBUG
38
39 void * lash_xmalloc (size_t);
40 void * lash_xrealloc (void *, size_t);
41 char * lash_xstrdup (const char *);
42
lash_malloc(size_t s)43 inline static void * lash_malloc(size_t s) { return lash_xmalloc(s); }
lash_realloc(void * a,size_t s)44 inline static void * lash_realloc(void* a, size_t s) { return lash_xrealloc(a, s); }
lash_strdup(const char * s)45 inline static char * lash_strdup(const char* s) { return lash_xstrdup(s); }
46
47 #else
48
49 inline static void * lash_malloc(size_t s) { return malloc(s); }
50 inline static void * lash_realloc(void* a, size_t s) { return realloc(a, s); }
51 inline static char * lash_strdup(const char* s) { return strdup(s); }
52
53 #endif
54
55 void * lash_malloc0 (size_t);
56
57
58 #ifdef __cplusplus
59 }
60 #endif
61
62 #endif /* __LASH_XMALLOC_H__ */
63