19 |
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
20 |
|
* USA |
21 |
|
* |
22 |
< |
* $Id: memory.h,v 7.41 2005/08/06 11:01:14 michael Exp $ |
22 |
> |
* $Id$ |
23 |
|
*/ |
24 |
|
|
25 |
|
#ifndef _I_MEMORY_H |
26 |
|
#define _I_MEMORY_H |
27 |
|
|
28 |
|
#include "ircd_defs.h" |
29 |
< |
#include "setup.h" |
30 |
< |
#include "balloc.h" |
31 |
< |
|
32 |
< |
/* Needed to use uintptr_t for some pointer manipulation. */ |
33 |
< |
|
34 |
< |
#ifdef HAVE_INTTYPES_H |
35 |
< |
# include <inttypes.h> |
36 |
< |
#else /* No inttypes.h */ |
37 |
< |
# ifndef HAVE_UINTPTR_T |
38 |
< |
typedef unsigned long uintptr_t; |
39 |
< |
# endif |
40 |
< |
#endif |
29 |
> |
#include "config.h" |
30 |
|
|
31 |
|
extern void outofmemory(void); |
32 |
|
|
33 |
< |
extern void *MyMalloc(size_t size); |
34 |
< |
extern void *MyRealloc(void *x, size_t y); |
35 |
< |
extern void MyFree(void *x); |
36 |
< |
extern void _DupString(char **x, const char *y); |
48 |
< |
|
49 |
< |
/* forte (and maybe others) don't like double declarations, |
50 |
< |
* so we don't declare the inlines unless GNUC |
51 |
< |
*/ |
52 |
< |
#ifdef __GNUC__ |
53 |
< |
extern inline void * |
54 |
< |
MyMalloc(size_t size) |
55 |
< |
{ |
56 |
< |
void *ret = calloc(1, size); |
57 |
< |
|
58 |
< |
if (ret == NULL) |
59 |
< |
outofmemory(); |
60 |
< |
return(ret); |
61 |
< |
} |
62 |
< |
|
63 |
< |
extern inline void * |
64 |
< |
MyRealloc(void *x, size_t y) |
65 |
< |
{ |
66 |
< |
void *ret = realloc(x, y); |
67 |
< |
|
68 |
< |
if (ret == NULL) |
69 |
< |
outofmemory(); |
70 |
< |
return(ret); |
71 |
< |
} |
72 |
< |
|
73 |
< |
extern inline void |
74 |
< |
MyFree(void *x) |
75 |
< |
{ |
76 |
< |
if (x != NULL) |
77 |
< |
free(x); |
78 |
< |
} |
79 |
< |
|
80 |
< |
extern inline void |
81 |
< |
_DupString(char **x, const char *y) |
82 |
< |
{ |
83 |
< |
(*x) = malloc(strlen(y) + 1); |
84 |
< |
|
85 |
< |
if (x == NULL) |
86 |
< |
outofmemory(); |
87 |
< |
strcpy((*x), y); |
88 |
< |
} |
89 |
< |
#endif /* __GNUC__ */ |
33 |
> |
extern void *MyMalloc(size_t); |
34 |
> |
extern void *MyRealloc(void *, size_t); |
35 |
> |
extern void MyFree(void *); |
36 |
> |
extern void _DupString(char **, const char *); |
37 |
|
|
38 |
|
#define DupString(x,y) _DupString(&x, y) |
39 |
+ |
|
40 |
+ |
#ifndef NDEBUG |
41 |
+ |
extern void mem_frob(void *, int); |
42 |
+ |
#else |
43 |
+ |
#define mem_frob(x, y) |
44 |
+ |
#endif |
45 |
|
#endif /* _I_MEMORY_H */ |