File: zmalloc.h

package info (click to toggle)
zmailer 2.99.51.52pre3-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 16,596 kB
  • ctags: 7,422
  • sloc: ansic: 90,470; sh: 3,608; makefile: 2,784; perl: 1,585; python: 115; awk: 22
file content (99 lines) | stat: -rw-r--r-- 3,795 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*  Author: Mark Moraes <moraes@csri.toronto.edu> */
/* $Id: zmalloc.h,v 1.1 1999/06/26 13:23:25 mea Exp $ */
#ifndef __XMALLOC_H__
#define __XMALLOC_H__

#if defined(ANSI_TYPES) || defined(HAVE_UNISTD_H) || defined(__STDC__)
#define univptr_t		void *
#else	/* ! ANSI_TYPES */
#define univptr_t		char *
#define	size_t		unsigned int
#endif	/* ANSI_TYPES */

#if defined(ANSI_TYPES) && !defined(__STDC__)
#define size_t		unsigned long
#endif

#if defined(__STDC__)
#define __proto(x)	x
#else
#define __proto(x)	()
#endif

/*
 *  defined so users of new features of this malloc can #ifdef
 *  invocations of those features.
 */
#define CSRIMALLOC

#ifdef MALLOC_TRACE
/* Tracing malloc definitions - helps find leaks */

extern univptr_t __malloc __proto((const size_t, const char *, const int));
extern univptr_t __calloc __proto((const size_t, const size_t, const char *, const int));
extern univptr_t __realloc __proto((univptr_t, const size_t, const char *, const int));
extern univptr_t __valloc __proto((const size_t, const char *, const int));
extern univptr_t __memalign __proto((const size_t, size_t, const char *, const int));
extern univptr_t __emalloc __proto((const size_t, const char *, const int));
extern univptr_t __ecalloc __proto((const size_t, const size_t, const char *, const int));
extern univptr_t __erealloc __proto((univptr_t, const size_t, const char *, const int));
extern char *__strdup __proto((const char *, const char *, int));
extern char *__strsave __proto((const char *, const char *, const int));
extern void ___free __proto((univptr_t, const char *, int));
extern void ___cfree __proto((univptr_t, const char *, int));

#define malloc(x)		___malloc((x), __FILE__, __LINE__)
#define calloc(x, n)		___calloc((x), (n), __FILE__, __LINE__)
#define realloc(p, x)		__realloc((p), (x), __FILE__, __LINE__)
#define memalign(x, n)		__memalign((x), (n), __FILE__, __LINE__)
#define valloc(x)		__valloc((x), __FILE__, __LINE__)
#define emalloc(x)		__emalloc((x), __FILE__, __LINE__)
#define ecalloc(x, n)		__ecalloc((x), (n), __FILE__, __LINE__)
#define erealloc(p, x)		__erealloc((p), (x), __FILE__, __LINE__)
#define strdup(p)		__strdup((p), __FILE__, __LINE__)
#define strsave(p)		__strsave((p), __FILE__, __LINE__)
/* cfree and free are identical */
#define cfree(p)		___free((p), __FILE__, __LINE__)
#define free(p)			___free((p), __FILE__, __LINE__)

#else /* MALLOC_TRACE */

#ifndef HAVE_STDLIB_H
extern univptr_t malloc   __proto((size_t));
extern univptr_t calloc   __proto((size_t, size_t));
extern univptr_t realloc  __proto((univptr_t, size_t));
extern void free  __proto((univptr_t));
extern char     *strdup   __proto((const char *));
#endif
extern univptr_t valloc   __proto((size_t));
extern univptr_t memalign __proto((size_t, size_t));
extern univptr_t emalloc  __proto((size_t));
extern univptr_t ecalloc  __proto((size_t, size_t));
extern univptr_t erealloc __proto((univptr_t, size_t));
extern char * strsave  __proto((const char *));
extern char * strnsave __proto((const char *, const size_t));
extern void cfree __proto((univptr_t));

#endif /* MALLOC_TRACE */

extern void mal_debug __proto((int));
extern void mal_dumpleaktrace __proto((FILE *));
extern void mal_heapdump __proto((FILE *));
extern void mal_leaktrace __proto((int));
extern void mal_sbrkset __proto((int));
extern void mal_slopset __proto((int));
extern void mal_statsdump __proto((FILE*));
extern void mal_setstatsfile __proto((FILE *));
extern void mal_trace __proto((int));
extern int  mal_verify __proto((int));
extern void mal_mmap __proto((char *));


/* Just in case you want an ANSI malloc without an ANSI compiler */
#if defined(ANSI_TYPES) && !defined(__STDC__)
#undef size_t
#endif

#undef __proto

#endif /* __XMALLOC_H__ */ /* Do not add anything after this line */