summaryrefslogtreecommitdiff
path: root/mmm.h
blob: 7232b5276a2df2fb475ff1af931b0789e19b4037 (plain) (blame)
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
#ifndef __LIBMM_MMM_H
#define __LIBMM_MMM_H

#define _GNU_SOURCE

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <dlfcn.h>

#include "mmm_config.h"

//----------------------------------------------------------------------
#ifdef MMM_PLAIN

#define MALLOC(SIZE) malloc(SIZE);
#define FREE(PTR) free(PTR);
#define CALLOC(NMEMB,SIZE) calloc(NMEMB, SIZE);
#define REALLOC(PTR,SIZE) realloc(PTR,SIZE);
#define IF_NULL(PTR,SUCCESS_CODE,FAILED_CODE) if ((PTR)==NULL){FAILED_CODE} else {SUCCESS_CODE};

#endif

//----------------------------------------------------------------------
#ifdef MMM_PLAIN_SAFE

#define MALLOC(SIZE) malloc(SIZE);
#define FREE(PTR) if (PTR!=NULL){free(PTR);PTR=NULL;};
#define CALLOC(NMEMB,SIZE) calloc(NMEMB, SIZE);
#define REALLOC(PTR,SIZE) realloc(PTR,SIZE);
#define IF_NULL(PTR,SUCCESS_CODE,FAILED_CODE) if ((PTR)==NULL){FAILED_CODE} else {SUCCESS_CODE};

#endif

//----------------------------------------------------------------------
#ifdef MMM_RECORD

#define MALLOC(SIZE) mmm_malloc(SIZE,__FILE__,__LINE__);
#define FREE(PTR) mmm_free((PTR),__FILE__,__LINE__);
#define CALLOC(NMEMB,SIZE) calloc(NMEMB,SIZE);
#define REALLOC(PTR,SIZE) realloc(PTR,SIZE);
#define IF_NULL(PTR,SUCCESS_CODE,FAILED_CODE) if ((PTR)==NULL){FAILED_CODE} else {SUCCESS_CODE};


void* mmm_malloc(size_t, const char *, int );
void mmm_free( void *, const char *, int );

#endif




#endif