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
|
#include "sci_mem_alloc.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/* Allan CORNET */
/* INRIA 2005 */
#ifndef NULL
#define NULL 0
#endif
/*-----------------------------------------------------------------------------------*/
void * MyReAlloc(void * lpAddress,int dwSize,char *fichier,int ligne)
{
void * NewPointer=NULL;
NewPointer = realloc(lpAddress,dwSize);
if(NewPointer == NULL)
{
#ifndef NDEBUG
printf("REALLOC returns NULL Error File %s Line %d \n",fichier,ligne);
fflush(NULL);
#endif
}
/*printf("MyRealloc %d %s %d\n",lpAddress,fichier,ligne);*/
return NewPointer;
}
/*-----------------------------------------------------------------------------------*/
void * MyAlloc(unsigned int dwSize,char *fichier,int ligne)
{
void * NewPointer=NULL;
if (dwSize>0)
{
NewPointer = malloc(dwSize);
if (NewPointer == NULL)
{
#ifndef NDEBUG
printf("MALLOC returns NULL Error File %s Line %d \n",fichier,ligne);
fflush(NULL);
#endif
}
}
else
{
NewPointer = malloc(dwSize);
#ifndef NDEBUG
printf("MALLOC incorrect Size Error File %s Line %d \n",fichier,ligne);
fflush(NULL);
#endif
}
/*printf("MyAlloc %d %s %d\n",NewPointer,fichier,ligne);*/
return NewPointer;
}
/*-----------------------------------------------------------------------------------*/
void * MyCalloc(unsigned int x, unsigned int y, char *fichier,int ligne)
{
void * NewPointer=NULL;
if ((x)*(y)>0)
{
NewPointer = calloc(x,y);
if (NewPointer == NULL)
{
#ifndef NDEBUG
printf("CALLOC returns NULL Error File %s Line %d \n",fichier,ligne);
fflush(NULL);
#endif
}
}
else
{
NewPointer = calloc(x,y);
#ifndef NDEBUG
printf("CALLOC incorrect size Error File %s Line %d \n",fichier,ligne);
fflush(NULL);
#endif
}
/*printf("MyCalloc %d %s %d\n",NewPointer,fichier,ligne);*/
return NewPointer;
}
/*-----------------------------------------------------------------------------------*/
void MyFree(void *x, char *fichier,int ligne)
{
free((void*)x);
/*printf("MyFree %d %s %d\n",x,fichier,ligne);*/
}
/*-----------------------------------------------------------------------------------*/
|