1 /*
2  * Copyright (C) 2004, 2005  Nils R. Weller
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program 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.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  */
18 
19 #ifndef N_LIBC_H
20 #define N_LIBC_H
21 
22 #include <stdio.h>
23 #include <stdarg.h>
24 #include <sys/types.h>
25 #include <sys/mman.h>
26 
27 char	*n_strdup(const char *msg);
28 void	*n_memdup(const void *data, size_t len);
29 void	n_xmalloc_set_guard(size_t nbytes);
30 void	*n_xmalloc(size_t nbytes);
31 void	*n_xrealloc(void *block, size_t nbytes);
32 char	*n_xstrdup(const char *msg);
33 void	*n_xmemdup(const void *data, size_t len);
34 void	make_room(char **p, size_t *size, size_t nbytes);
35 void	x_fprintf(FILE *fd, const char *fmt, ...);
36 void	x_fputc(int ch, FILE *fd);
37 void	*debug_malloc_pages(size_t nbytes);
38 void	unimpl(void);
39 
40 #if 0
41 #define DEBUG_REALLOC
42 #define DEBUG_FREE
43 #define DEBUG_MALLOC
44 #endif
45 
46 #ifdef DEBUG_MALLOC
47 #define n_xmalloc(x) n_xmalloc((x) + 50)
48 #endif
49 
50 #ifdef DEBUG_REALLOC
51 #define n_xrealloc(x, y) n_xrealloc((x), (y) + 128)
52 #endif
53 
54 #ifdef DEBUG_FREE
55 #undef free
56 #define free(x) ((void) x)
57 #endif
58 
59 #endif
60 
61