Initial import from FreeBSD RELENG_4:
[dragonfly.git] / contrib / libpam / libpam / include / security / pam_malloc.h
1 /* $Id: pam_malloc.h,v 1.1 1996/11/10 21:23:14 morgan Exp $
2  * $FreeBSD: src/contrib/libpam/libpam/include/security/pam_malloc.h,v 1.1.1.1.6.2 2001/06/11 15:28:14 markm Exp $
3  *
4  * $Log: pam_malloc.h,v $
5  * Revision 1.1  1996/11/10 21:23:14  morgan
6  * Initial revision
7  *
8  */
9
10 /*
11  * This file (via the use of macros) defines a wrapper for the malloc
12  * family of calls. It logs where the memory was requested and also
13  * where it was free()'d and keeps a list of currently requested memory.
14  *
15  * It is hoped that it will provide some help in locating memory leaks.
16  */
17
18 #ifndef PAM_MALLOC_H
19 #define PAM_MALLOC_H
20
21 /* these are the macro definitions for the stdlib.h memory functions */
22
23 #define malloc(s)      pam_malloc(s,__FILE__,__FUNCTION__,__LINE__)
24 #define calloc(n,s)    pam_calloc(n,s,__FILE__,__FUNCTION__,__LINE__)
25 #define free(x)        pam_free(x,__FILE__,__FUNCTION__,__LINE__)
26 /* #define memalign(a,s)  pam_memalign(a,s,__FILE__,__FUNCTION__,__LINE__) */
27 #define realloc(x,s)   pam_realloc(x,s,__FILE__,__FUNCTION__,__LINE__)
28 /* #define valloc(s)      pam_valloc(s,__FILE__,__FUNCTION__,__LINE__) */
29 /* #define alloca(s)      pam_alloca(s,__FILE__,__FUNCTION__,__LINE__) */
30 #define exit(i)        pam_exit(i,__FILE__,__FUNCTION__,__LINE__)
31
32 /* these are the prototypes for the wrapper functions */
33
34 #include <sys/types.h>
35
36 extern void *pam_malloc(size_t s,const char *,const char *,const int);
37 extern void *pam_calloc(size_t n,size_t s,const char *,const char *,const int);
38 extern void  pam_free(void *x,const char *,const char *,const int);
39 extern void *pam_memalign(size_t a,size_t s
40                          ,const char *,const char *,const int);
41 extern void *pam_realloc(void *x,size_t s,const char *,const char *,const int);
42 extern void *pam_valloc(size_t s,const char *,const char *,const int);
43 extern void *pam_alloca(size_t s,const char *,const char *,const int);
44 extern void  pam_exit(int i,const char *,const char *,const int);
45
46 /* these are the flags used to turn on and off diagnostics */
47
48 #define PAM_MALLOC_LEAKED             01
49 #define PAM_MALLOC_REQUEST            02
50 #define PAM_MALLOC_FREE               04
51 #define PAM_MALLOC_EXCH               (PAM_MALLOC_FREED|PAM_MALLOC_EXCH)
52 #define PAM_MALLOC_RESIZE            010
53 #define PAM_MALLOC_FAIL              020
54 #define PAM_MALLOC_NULL              040
55 #define PAM_MALLOC_VERIFY           0100
56 #define PAM_MALLOC_FUNC             0200
57 #define PAM_MALLOC_PAUSE            0400
58 #define PAM_MALLOC_STOP            01000
59
60 #define PAM_MALLOC_ALL              0777
61
62 #define PAM_MALLOC_DEFAULT     \
63   (PAM_MALLOC_LEAKED|PAM_MALLOC_PAUSE|PAM_MALLOC_FAIL)
64
65 #include <stdio.h>
66
67 extern FILE *pam_malloc_outfile;      /* defaults to stdout */
68
69 /* how much output do you want? */
70
71 extern int pam_malloc_flags;
72 extern int pam_malloc_delay_length;      /* how long to pause on errors */
73
74 #endif /* PAM_MALLOC_H */