File: malloc.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 (116 lines) | stat: -rw-r--r-- 3,973 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*  Author: Mark Moraes <moraes@csri.toronto.edu> */
/* $Id: malloc.h,v 1.1.1.1 1998/02/10 21:01:46 mea Exp $ */
#ifndef __XMALLOC_H__
#define __XMALLOC_H__

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

#if defined(ANSI_TYPES) && !defined(__STDC__) && !defined(HAVE_CONFIG_H)
#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((size_t, const char *, int));
extern univptr_t __calloc __proto((size_t, size_t, const char *, int));
extern univptr_t __realloc __proto((univptr_t, size_t, const char *, int));
extern univptr_t __valloc __proto((size_t, const char *, int));
extern univptr_t __memalign __proto((size_t, size_t, const char *, int));
extern univptr_t __emalloc __proto((size_t, const char *, int));
extern univptr_t __ecalloc __proto((size_t, size_t, const char *, int));
extern univptr_t __erealloc __proto((univptr_t, size_t, const char *, int));
extern char *__strdup __proto((const char *, const char *, int));
extern char *__strsave __proto((const char *, const char *, 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 */

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 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 *strdup __proto((const char *));
extern char *strsave __proto((const char *));
extern void free __proto((univptr_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(());
extern void mal_setstatsfile __proto((FILE *));
extern void mal_trace __proto((int));
extern int mal_verify __proto((int));
extern void mal_mmap __proto((char *));


/*
 *  You may or may not want this - In gcc version 1.30, on Sun3s running
 *  SunOS3.5, this works fine.
 */
#ifdef __GNUC__
#define alloca(n) __builtin_alloca(n)
#endif /* __GNUC__ */
#ifdef sparc
#define alloca(n) __builtin_alloca(n)
#endif /* sparc */

#ifdef ANSI_TYPES
#undef univptr_t
#else	/* ! ANSI_TYPES */
#undef univptr_t
#undef size_t
#endif	/* ANSI_TYPES */

/* 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 */