Commit 07a68777 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

dmemory: cleanup

parent 85b1032a
......@@ -47,9 +47,9 @@ typedef struct
char file[MAXNAME];
char caller[MAXNAME];
}
MemTable;
MemTable_t;
static MemTable *memTable;
static MemTable_t* memTable;
static int memTableSize = 0;
static long memAccess = 0;
......@@ -86,8 +86,8 @@ static
void memError(const char *caller, const char *file, int line, size_t size)
{
printf("\n");
fprintf(stderr, "Error (%s) : Allocation of %lu bytes failed. [ line %d file %s ]\n",
caller, (unsigned long) size, line, file);
fprintf(stderr, "Error (%s) : Allocation of %zu bytes failed. [ line %d file %s ]\n",
caller, size, line, file);
if ( errno ) perror("System error message ");
......@@ -115,7 +115,7 @@ void memListPrintEntry(int mtype, int item, size_t size, void *ptr,
}
fprintf(stderr, "memory item %3d ", item);
fprintf(stderr, "(%6lu byte) ", (unsigned long) size);
fprintf(stderr, "(%6zu byte) ", size);
fprintf(stderr, "at %p", ptr);
if ( file != NULL )
{
......@@ -270,8 +270,8 @@ int memListNewEntry(int mtype, void *ptr, size_t size, size_t nobj,
if ( memTableSize == 0 )
{
memTableSize = 8;
memSize = memTableSize*sizeof(MemTable);
memTable = (MemTable *) malloc(memSize);
memSize = memTableSize*sizeof(MemTable_t);
memTable = (MemTable_t*) malloc(memSize);
if( memTable == NULL ) memError(__func__, __FILE__, __LINE__, memSize);
for( i = 0; i < memTableSize; i++ )
......@@ -291,8 +291,8 @@ int memListNewEntry(int mtype, void *ptr, size_t size, size_t nobj,
if ( memID == memTableSize )
{
memTableSize = 2*memTableSize;
memSize = memTableSize*sizeof(MemTable);
memTable = (MemTable *) realloc(memTable, memSize);
memSize = memTableSize*sizeof(MemTable_t);
memTable = (MemTable_t*) realloc(memTable, memSize);
if( memTable == NULL ) memError(__func__, __FILE__, __LINE__, memSize);
for( i = memID; i < memTableSize; i++ )
......
......@@ -29,15 +29,15 @@ extern void Free (const char *caller, const char *file, int line, void *ptr
#endif
#if defined WITH_CALLER_NAME
# define realloc(p, s) Realloc(__func__, __FILE__, __LINE__, p, (size_t)s)
# define calloc(n, s) Calloc(__func__, __FILE__, __LINE__, n, (size_t)s)
# define malloc(s) Malloc(__func__, __FILE__, __LINE__, (size_t)s)
# define free(p) Free(__func__, __FILE__, __LINE__, p)
# define realloc(p, s) Realloc(__func__, __FILE__, __LINE__, (p), (s))
# define calloc(n, s) Calloc(__func__, __FILE__, __LINE__, (n), (s))
# define malloc(s) Malloc(__func__, __FILE__, __LINE__, (s))
# define free(p) Free(__func__, __FILE__, __LINE__, (p))
#else
# define realloc(p, s) Realloc((void *) NULL, __FILE__, __LINE__, p, (size_t)s)
# define calloc(n, s) Calloc((void *) NULL, __FILE__, __LINE__, n, (size_t)s)
# define malloc(s) Malloc((void *) NULL, __FILE__, __LINE__, (size_t)s)
# define free(p) Free((void *) NULL, __FILE__, __LINE__, p)
# define realloc(p, s) Realloc((void *) NULL, __FILE__, __LINE__, (p), (s))
# define calloc(n, s) Calloc((void *) NULL, __FILE__, __LINE__, (n), (s))
# define malloc(s) Malloc((void *) NULL, __FILE__, __LINE__, (s))
# define free(p) Free((void *) NULL, __FILE__, __LINE__, (p))
#endif
#endif /* DEBUG_MEMORY */
......@@ -46,12 +46,10 @@ void *cdiXmalloc(size_t, const char *, const char *, int);
#define xmalloc(size) cdiXmalloc((size), __FILE__, __func__, __LINE__ )
void *cdiXcalloc(size_t, size_t, const char *, const char *, int);
#define xcalloc(nmemb,size) cdiXcalloc((nmemb), (size), \
__FILE__, __func__, __LINE__)
#define xcalloc(nmemb,size) cdiXcalloc((nmemb), (size), __FILE__, __func__, __LINE__)
void *cdiXrealloc(void *, size_t, const char *, const char *, int);
#define xrealloc(p,size) cdiXrealloc((p), (size), \
__FILE__, __func__, __LINE__)
#define xrealloc(p,size) cdiXrealloc((p), (size), __FILE__, __func__, __LINE__)
#endif /* _DMEMORY_H */
/*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment