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
|
/****************************************************************
Copyright (C) 1986-2000 by
F6FBB - Jean-Paul ROUBELAT
6, rue George Sand
31120 - Roquettes - France
jpr@f6fbb.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Parts of code have been taken from many other softwares.
Thanks for the help.
****************************************************************/
#ifndef __FORTIFY_H__
#define __FORTIFY_H__
/*
* FILE:
* fortify.h
*
* DESCRIPTION:
* Header file for fortify.c - A fortified shell for malloc, realloc,
* calloc & free
*
* WRITTEN:
* spb 29/4/94
*
* VERSION:
* 1.0 29/4/94
*/
#include <stdlib.h>
#ifdef __cplusplus
extern "C"
{
#endif
typedef void (*OutputFuncPtr) (char *);
void *Fortify_malloc (size_t size, char *file, unsigned long line);
void *Fortify_realloc (void *ptr, size_t new_size, char *file, unsigned long line);
void *Fortify_calloc (size_t num, size_t size, char *file, unsigned long line);
void Fortify_free (void *uptr, char *file, unsigned long line);
char *Fortify_strdup (char *str, char *file, unsigned long line);
int Fortify_OutputAllMemory (char *file, unsigned long line);
int Fortify_CheckAllMemory (char *file, unsigned long line);
int Fortify_CheckPointer (void *uptr, char *file, unsigned long line);
int Fortify_Disable (char *file, unsigned long line);
int Fortify_SetMallocFailRate (int Percent);
int Fortify_EnterScope (char *file, unsigned long line);
int Fortify_LeaveScope (char *file, unsigned long line);
int Fortify_DumpAllMemory (int scope, char *file, unsigned long line);
void *Fortify_m_alloue (size_t size, char *file, unsigned long line);
void Fortify_m_libere (void *uptr, unsigned int taille, char *file, unsigned long line);
typedef void (*Fortify_OutputFuncPtr) (const char *);
Fortify_OutputFuncPtr Fortify_SetOutputFunc (Fortify_OutputFuncPtr Output);
#ifdef __cplusplus
}
#endif
#ifndef __FORTIFY_C__ /* Only define the macros if we're NOT in fortify.c */
#ifdef FORTIFY /* Add file and line information to the fortify calls */
#define malloc(size) Fortify_malloc(size, __FILE__, __LINE__)
#define realloc(ptr,new_size) Fortify_realloc(ptr, new_size, __FILE__, __LINE__)
#define calloc(num,size) Fortify_calloc(num, size, __FILE__, __LINE__)
#define free(ptr) Fortify_free(ptr, __FILE__, __LINE__)
#define strdup(str) Fortify_strdup(str, __FILE__, __LINE__)
#define m_alloue(num) Fortify_m_alloue(num, __FILE__, __LINE__)
#define m_libere(ptr, num) Fortify_m_libere(ptr, num, __FILE__, __LINE__)
#define Fortify_OutputAllMemory() Fortify_OutputAllMemory(__FILE__, __LINE__)
#define Fortify_CheckAllMemory() Fortify_CheckAllMemory(__FILE__, __LINE__)
#define Fortify_CheckPointer(ptr) Fortify_CheckPointer(ptr, __FILE__, __LINE__)
#define Fortify_Disable() Fortify_Disable(__FILE__, __LINE__)
#define Fortify_EnterScope() Fortify_EnterScope(__FILE__, __LINE__)
#define Fortify_LeaveScope() Fortify_LeaveScope(__FILE__, __LINE__)
#define Fortify_DumpAllMemory(s) Fortify_DumpAllMemory(s,__FILE__, __LINE__)
#else /* FORTIFY Define the special fortify functions away to nothing */
#define Fortify_OutputAllMemory() 0
#define Fortify_CheckAllMemory() 0
#define Fortify_CheckPointer(ptr) 1
#define Fortify_Disable() 1
#define Fortify_SetOutputFunc() 0
#define Fortify_SetMallocFailRate(p) 0
#define Fortify_EnterScope() 0
#define Fortify_LeaveScope() 0
#define Fortify_DumpAllMemory(s) 0
#endif /* FORTIFY */
#endif /* __FORTIFY_C__ */
#endif /* __FORTIFY_H__ */
|