root/1.8.3/tags/p6/hdrs/csrimalloc.h

Revision 1032, 3.6 KB (checked in by shawnw, 18 months ago)

Merged 1.8.3p4 into trunk

Line 
1/*  Author: Mark Moraes <moraes@csri.toronto.edu> */
2
3/* Modified by Alan Schwartz for PennMUSH.
4 * Should be included after config.h
5 */
6
7#ifndef __CSRIMALLOC_H
8#define __CSRIMALLOC_H
9
10#include "config.h"
11#define univptr_t               Malloc_t
12#define memsize_t               size_t
13#include "confmagic.h"
14
15/*
16 *  defined so users of new features of this malloc can #ifdef
17 *  invocations of those features.
18 */
19#define CSRIMALLOC
20
21#ifdef CSRI_TRACE
22/* Tracing malloc definitions - helps find leaks */
23
24univptr_t trace__malloc(size_t nbytes, const char *fname, int linenum);
25univptr_t trace__calloc
26  (size_t nelem, size_t elsize, const char *fname, int linenum);
27univptr_t trace__realloc
28  (univptr_t cp, size_t nbytes, const char *fname, int linenum);
29univptr_t trace__valloc(size_t size, const char *fname, int linenum);
30univptr_t trace__memalign
31  (size_t alignment, size_t size, const char *fname, int linenum);
32univptr_t trace__emalloc(size_t nbytes, const char *fname, int linenum);
33univptr_t trace__ecalloc
34  (size_t nelem, size_t sz, const char *fname, int linenum);
35univptr_t trace__erealloc
36  (univptr_t ptr, size_t nbytes, const char *fname, int linenum);
37char *trace__strdup(const char *s, const char *fname, int linenum);
38char *trace__strsave(const char *s, const char *fname, int linenum);
39void trace__free(univptr_t cp, const char *fname, int linenum);
40void trace__cfree(univptr_t cp, const char *fname, int linenum);
41
42#define malloc(x)               trace__malloc((x), __FILE__, __LINE__)
43#define calloc(x, n)            trace__calloc((x), (n), __FILE__, __LINE__)
44#define realloc(p, x)           trace__realloc((p), (x), __FILE__, __LINE__)
45#define memalign(x, n)          trace__memalign((x), (n), __FILE__, __LINE__)
46#define valloc(x)               trace__valloc((x), __FILE__, __LINE__)
47#define emalloc(x)              trace__emalloc((x), __FILE__, __LINE__)
48#define ecalloc(x, n)           trace__ecalloc((x), (n), __FILE__, __LINE__)
49#define erealloc(p, x)          trace__erealloc((p), (x), __FILE__, __LINE__)
50#define strdup(p)               trace__strdup((p), __FILE__, __LINE__)
51#define strsave(p)              trace__strsave((p), __FILE__, __LINE__)
52/* cfree and free are identical */
53#define cfree(p)                trace__free((p), __FILE__, __LINE__)
54#define free(p)                 trace__free((p), __FILE__, __LINE__)
55
56#else                           /* CSRI_TRACE */
57
58univptr_t malloc(size_t nbytes);
59univptr_t calloc(size_t nelem, size_t elsize);
60univptr_t realloc(univptr_t cp, size_t nbytes);
61univptr_t valloc(size_t size);
62univptr_t memalign(size_t alignment, size_t size);
63univptr_t emalloc(size_t nbytes);
64univptr_t ecalloc(size_t nelem, size_t sz);
65univptr_t erealloc(univptr_t ptr, size_t nbytes);
66char *strdup(const char *s);
67char *strsave(const char *s);
68void free(univptr_t cp);
69void cfree(univptr_t cp);
70
71#endif                          /* CSRI_TRACE */
72
73void mal_debug(int level);
74void mal_dumpleaktrace(FILE * fp);
75void mal_heapdump(FILE * fp);
76void mal_leaktrace(int value);
77void mal_sbrkset(int n);
78void mal_slopset(int n);
79void mal_statsdump(FILE * fp);
80void mal_setstatsfile(FILE * fp);
81void mal_trace(int value);
82int mal_verify(int fullcheck);
83void mal_mmap(char *fname);
84
85
86/*
87 *  You may or may not want this - In gcc version 1.30, on Sun3s running
88 *  SunOS3.5, this works fine.
89 */
90#ifdef __GNUC__
91#ifndef alloca
92#define alloca(n) __builtin_alloca(n)
93#endif
94#endif                          /* __GNUC__ */
95#ifdef sparc
96#define alloca(n) __builtin_alloca(n)
97#endif                          /* sparc */
98
99
100#endif  /* __CSRIMALLOC_H__ */                        /* Do not add anything after this line */
Note: See TracBrowser for help on using the browser.