2 * IRC - Internet Relay Chat, include/ircd_alloc.h
3 * Copyright (C) 1999 Thomas Helvey <tomh@inxpress.net>
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, or (at your option)
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 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 * Commentary by Bleep (Thomas Helvey)
24 #ifndef INCLUDED_ircd_alloc_h
25 #define INCLUDED_ircd_alloc_h
28 * memory resource allocation and test functions
30 typedef void (*OutOfMemoryHandler)(void);
31 extern void set_nomem_handler(OutOfMemoryHandler handler);
35 * RELEASE: allocation functions
37 #ifndef INCLUDED_stdlib_h
38 #include <stdlib.h> /* free */
39 #define INCLUDED_stdlib_h
42 #define MyFree(x) do { free((x)); (x) = 0; } while(0)
44 extern void* MyMalloc(size_t size);
45 extern void* MyCalloc(size_t nelem, size_t size);
46 extern void* MyRealloc(void* p, size_t size);
48 #else /* !defined(NDEBUG) */
50 * DEBUG: allocation functions
52 #ifndef INCLUDED_fda_h
56 #define MyMalloc(s) fda_malloc((s), __FILE__, __LINE__)
57 #define MyCalloc(n, s) fda_calloc((n), (s), __FILE__, __LINE__)
58 #define MyFree(p) fda_free((p))
59 #define MyRealloc(p, s) fda_realloc((p), (s), __FILE__, __LINE__)
61 #endif /* !defined(NDEBUG) */
63 #endif /* INCLUDED_ircd_alloc_h */