Debian Codegraph @

deps/libneon/src/ne_alloc.h

raw
1 /*
2 Replacement memory allocation handling etc.
3 Copyright (C) 1999-2005, Joe Orton <[email protected]>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 MA 02111-1307, USA
19
20 */
21
22 #ifndef NE_ALLOC_H
23 #define NE_ALLOC_H
24
25 #include <stdlib.h>
26
27 #ifndef WIN32
28 #include <sys/types.h>
29 #endif
30
31 #include "ne_defs.h"
32
33 NE_BEGIN_DECLS
34
35 typedef void (*ne_oom_callback_fn)(void);
36
37 /* Set callback which is called if malloc() returns NULL. */
38 void ne_oom_callback(ne_oom_callback_fn callback);
39
40 #ifndef NEON_MEMLEAK
41 /* Replacements for standard C library memory allocation functions,
42 * which never return NULL. If the C library malloc() returns NULL,
43 * neon will abort(); calling an OOM callback beforehand if one is
44 * registered. The C library will only ever return NULL if the
45 * operating system does not use optimistic memory allocation. */
46 void *ne_malloc(size_t size) ne_attribute_malloc;
47 void *ne_calloc(size_t size) ne_attribute_malloc;
48 void *ne_realloc(void *ptr, size_t s);
49 char *ne_strdup(const char *s) ne_attribute_malloc;
50 char *ne_strndup(const char *s, size_t n) ne_attribute_malloc;
51 #ifdef WIN32
52 void ne_free(void *ptr);
53 #else
54 #define ne_free free
55 #endif
56 #endif
57
58 NE_END_DECLS
59
60 #endif /* NE_ALLOC_H */