The Netsukuku Project  0.0.9
An Alternative routing method
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
xmalloc.h
Go to the documentation of this file.
1 /* This file is part of Netsukuku system
2  * (c) Copyright 2005 Andrea Lo Pumo aka AlpT <alpt@freaknet.org>
3  *
4  * This source code is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as published
6  * by the Free Software Foundation; either version 2 of the License,
7  * or (at your option) any later version.
8  *
9  * This source code is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12  * Please refer to the GNU Public License for more details.
13  *
14  * You should have received a copy of the GNU Public License along with
15  * this source code; if not, write to:
16  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  */
18 
19 #ifndef XMALLOC_H
20 #define XMALLOC_H
21 
22 #ifdef USE_DMALLOC
23 
24 #include "dmalloc.h"
25 
26 #else
27 
28 /* xmalloc.h: Shamelessly ripped from openssh:
29  * Author: Tatu Ylonen <ylo@cs.hut.fi>
30  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
31  * All rights reserved
32  * Created: Mon Mar 20 22:09:17 1995 ylo
33  *
34  * Versions of malloc and friends that check their results, and never return
35  * failure (they call fatal if they encounter an error).
36  *
37  * --
38  *
39  * xfree() macro wrapper added. AlpT
40  */
41 
42 /*
43  * xfree
44  *
45  * It calls _xfree(__pptr) and then sets `__pptr' to 0.
46  * It is safe, you can use it also with expressions:
47  * xfree(a++);
48  */
49 #define xfree(__pptr) \
50 do{ \
51  char **_p=(char **)&(__pptr); \
52  _xfree(*_p); \
53  *_p=0; \
54 }while(0)
55 
56 /* Functions declaration */
57 void *xmalloc(size_t);
58 void *xzalloc(size_t size);
59 void *xrealloc(void *, size_t);
60 void *xcalloc(size_t nmemb, size_t size);
61 void _xfree(void *);
62 char *xstrndup(const char *str, size_t n);
63 char *xstrdup(const char *);
64 
65 #endif
66 
67 #endif /*XMALLOC_H*/
char * xstrdup(const char *)
Definition: xmalloc.c:119
void * xcalloc(size_t nmemb, size_t size)
Definition: xmalloc.c:70
void * xzalloc(size_t size)
Definition: xmalloc.c:61
char * xstrndup(const char *str, size_t n)
Definition: xmalloc.c:106
void * xrealloc(void *, size_t)
Definition: xmalloc.c:83
void _xfree(void *)
Definition: xmalloc.c:99
void * xmalloc(size_t)
Definition: xmalloc.c:44