11#define DSDP_MAX_PATH_LEN 200
13static FILE *DSDPLogInfoFile = DSDP_NULL;
14static FILE *dsdp_history=0;
16typedef void* DSDPObject;
18int DSDPFError(
void *vobj,
const char functionname[],
int linen,
const char filename[],
const char message[], ...)
26 DSDPLogInfoFile = stdout;
33 va_start(Argp, message);
34 sprintf(
string,
"[%d] DSDP: %s(): Line %d in file %s ", urank,functionname,linen,filename);
37#if defined(DSDP_HAVE_VPRINTF_CHAR)
38 vsprintf(
string+len, message, (
char *) Argp);
40 vsprintf(
string+len, message, Argp);
42 fprintf(DSDPLogInfoFile,
"%s",
string);
43 fflush(DSDPLogInfoFile);
45#if defined(DSDP_HAVE_VPRINTF_CHAR)
46 vfprintf(dsdp_history, message, (
char *) Argp);
48 vfprintf(dsdp_history, message, Argp);
52 DSDPFunctionReturn(0);
56void DSDPError(
const char * functionname,
int linen,
const char filename[]){
57 DSDPErrorPrintf(
"DSDP Error in function: %s , line %d of file %s \n",functionname, linen,filename);
68static DSDPMemory DSDPMemoryTable[DSDPMEMMAX];
70static long int mmmem=0;
72#define __FUNCT__ "DSDPMMalloc"
73int DSDPMMalloc(
const char* fname,
size_t size,
void** mmem){
78 tt=(
void*)mxMalloc(size);
80 tt=(
void*)malloc(size);
84 DSDPSETERR3(100,
"Memory Error in routine '%s'. Cannot allocate %d bytes, %d MB\n",fname,size,(
int)(size/1000000));
89 if (mmmem<DSDPMEMMAX){
90 DSDPMemoryTable[mmmem].size=size;
91 DSDPMemoryTable[mmmem].freed=0;
92 strncpy(DSDPMemoryTable[mmmem].fname,fname,19);
93 DSDPMemoryTable[mmmem].mem=tt;
100 DSDPFunctionReturn(0);
104#define __FUNCT__ "DSDPFFree"
105int DSDPFFree(
void** mmem){
109 for (j=0;j<DSDPMEMMAX;j++){
110 if (*mmem==DSDPMemoryTable[j].mem){
111 DSDPMemoryTable[j].freed=1;
122 if (0==1 && gotit==0){
123 printf(
" DSDP MEMORY Error: Already Freed? \n");
126 DSDPFunctionReturn(0);
132 for (j=0;j<DSDPMEMMAX;j++){
133 if (DSDPMemoryTable[j].size>0 && DSDPMemoryTable[j].freed==0){
134 printf(
"%d, MEMORY Not FREED: %s, %d \n",j,DSDPMemoryTable[j].fname,(
int)DSDPMemoryTable[j].size);
138 DSDPLogInfo(0,2,
" MEMORY MALLOC NOT FREED: %ld\n",mmmem);
Error handling, printing, and profiling.