Hi,

attached patch removes the usage of STRING in the block,treap,mem part
of the lib/framework. The users are converted to 'char *' or 'const
char *'.

Please consider applying.

Regards,
Stefan

Index: lib/framework/block.h
===================================================================
--- lib/framework/block.h       (revision 354)
+++ lib/framework/block.h       (working copy)
@@ -34,11 +34,11 @@
        SDWORD          init, ext;              // initial and extension block 
sizes
        BLOCK_HEAP_MEM  *psBlocks;
 #ifdef DEBUG_BLOCK
-       STRING          *pFileName;
+       const char      *pFileName;
        SDWORD          line;
        MEM_NODE        *psMemTreap;    // treap of the memory blocks
        BOOL            free;                   // whether free has been called 
for this block
-       STRING          *pFreeFile;             // where the last free was 
called from
+       const char      *pFreeFile;             // where the last free was 
called from
        SDWORD          freeLine;       
        UDWORD          TotalAllocated; // Total amount of bytes used in the 
block (sum of all alloc's)
 #endif
@@ -82,7 +82,7 @@
 extern BOOL blkPointerValidAll(void *pData, SDWORD size);
 
 // Note the call position for a blkAlloc or blkFree
-extern void blkCallPos(STRING *pFileName, SDWORD line);
+extern void blkCallPos(const char *pFileName, SDWORD line);
 
 void blkPrintDetails(BLOCK_HEAP *psHeap);
 void blkReport(void);
Index: lib/framework/treap.c
===================================================================
--- lib/framework/treap.c       (revision 354)
+++ lib/framework/treap.c       (working copy)
@@ -18,15 +18,15 @@
 
 /* Position of the last call */
 static SDWORD  cLine;
-static STRING  *pCFile;
-static STRING  pCFileNone[] = "None";
+static char *pCFile;
+static char    pCFileNone[] = "None";
 
 /* Store the location in C code at which a call to the heap was made */
-void treapSetCallPos(STRING *pFileName, SDWORD lineNumber)
+void treapSetCallPos(const char *pFileName, SDWORD lineNumber)
 {
        cLine = lineNumber;
 
-       pCFile = (STRING *)MALLOC(strlen(pFileName) + 1);
+       pCFile = (char *)MALLOC(strlen(pFileName) + 1);
        if (pCFile)
        {
                strcpy(pCFile, pFileName);
@@ -57,8 +57,8 @@
 SDWORD treapStringCmp(UDWORD key1, UDWORD key2)
 {
        SDWORD result;
-       STRING  *pStr1 = (STRING *)key1;
-       STRING  *pStr2 = (STRING *)key2;
+       const char *pStr1 = (const char *)key1;
+       const char *pStr2 = (const char *)key2;
 
        result = strcmp(pStr1,pStr2);
        if (result<0) return -1;
Index: lib/framework/treap.h
===================================================================
--- lib/framework/treap.h       (revision 354)
+++ lib/framework/treap.h       (working copy)
@@ -45,7 +45,7 @@
 
 /* The debug info */
 #define TREAP_NODE_DEBUG \
-       STRING                          *pFile; /* file the node was created in 
*/ \
+       const char                      *pFile; /* file the node was created in 
*/ \
        SDWORD                          line    /* line the node was created at 
*/
 
 typedef struct _treap_node
@@ -66,7 +66,7 @@
        TREAP_NODE              *psRoot;        // root of the tree
 
 #ifdef DEBUG_TREAP
-       STRING                  *pFile;         // file the treap was created in
+       const char              *pFile;         // file the treap was created in
        SDWORD                  line;           // line the treap was created at
 #endif
 } TREAP;
@@ -78,7 +78,7 @@
 
 
 /* Store the location in C code at which a call to the heap was made */
-extern void treapSetCallPos(STRING *pFileName, SDWORD lineNumber);
+extern void treapSetCallPos(const char *pFileName, SDWORD lineNumber);
 
 /* Function type for object equality */
 //typedef BOOL (*TREAP_EQUAL)(void *pObj1, void *pObj2);
Index: lib/framework/mem.c
===================================================================
--- lib/framework/mem.c (revision 354)
+++ lib/framework/mem.c (working copy)
@@ -145,7 +145,7 @@
  * A buffer is also allocated at the top and bottom of the memory to check for
  * overwrites.
  */
-void *memMalloc(STRING *pFileName, SDWORD LineNumber, size_t Size)
+void *memMalloc(const char *pFileName, SDWORD LineNumber, size_t Size)
 {
        void            *pMemBase;
        MEM_NODE        *psNode;
@@ -172,7 +172,7 @@
 
        /* Got the main bit of memory - set up the node entry */
        psNode = (MEM_NODE *)pMemBase;
-       psNode->pFile = (STRING *)RMALLOC( strlen(pFileName)+1 );
+       psNode->pFile = (char *)RMALLOC( strlen(pFileName)+1 );
        if (!psNode->pFile)
        {
                RFREE(pMemBase);
@@ -229,7 +229,7 @@
  * All memory is reset to FREE_BYTE before freeing to avoid using
  * freed memory.
  */
-void memFree(STRING *pFileName, SDWORD LineNumber, void *pMemToFree)
+void memFree(const char *pFileName, SDWORD LineNumber, void *pMemToFree)
 {
        MEM_NODE        sNode, *psDeleted;
        SDWORD          i, InvalidBottom, InvalidTop;
@@ -483,7 +483,7 @@
  * If pFileName is not NULL send the report to the specified file.
  * If pFileName is NULL the report goes to DBPRINTF
  */
-void memMemoryReport(STRING *pFileName)
+void memMemoryReport(const char *pFileName)
 {
 #ifdef DEBUG_MALLOC
        SDWORD          TotMem;
@@ -511,7 +511,7 @@
 
 
 /* Display the memory treap */
-void memDisplayTreap(STRING *pFileName)
+void memDisplayTreap(const char *pFileName)
 {
 #ifdef DEBUG_MALLOC
        debug(LOG_MEMORY, "Memory Allocation Treap:");
Index: lib/framework/mem.h
===================================================================
--- lib/framework/mem.h (revision 354)
+++ lib/framework/mem.h (working copy)
@@ -42,21 +42,21 @@
 struct _block_heap *memGetBlockHeap(void);
 
 /* malloc replacements */
-void *memMalloc(STRING *pFileName, SDWORD LineNumber, size_t Size);
+void *memMalloc(const char *pFileName, SDWORD LineNumber, size_t Size);
 void *memMallocRelease(size_t Size);
 
 /* free replacements */
-void memFree(STRING *pFileName, SDWORD LineNumber, void *pMemToFree);
+void memFree(const char *pFileName, SDWORD LineNumber, void *pMemToFree);
 void memFreeRelease(void *pMemToFree);
 
 /* Check a pointer refers to a valid block of memory */
 BOOL memPointerValid(void *pPtr, size_t Size);
 
 /* Report on currently allocated memory */
-void memMemoryReport(STRING *pFileName);
+void memMemoryReport(const char *pFileName);
 
 /* Display the memory treap */
-void memDisplayTreap(STRING *pFileName);
+void memDisplayTreap(const char *pFileName);
 
 #ifdef DEBUG_MALLOC
 
Index: lib/framework/block.c
===================================================================
--- lib/framework/block.c       (revision 354)
+++ lib/framework/block.c       (working copy)
@@ -39,8 +39,8 @@
 #define MEMORY_SET             TRUE
 
 // the filename and line number of the last call to the block functions
-STRING *pCallFileName;
-SDWORD callLine;
+static const char *pCallFileName;
+static SDWORD  callLine;
 
 // the list of allocated blocks
 static BLOCK_HEAP      *psBlockList=NULL;
@@ -73,7 +73,7 @@
 }
 
 // Note the call position for a blkAlloc or blkFree
-void blkCallPos(STRING *pFileName, SDWORD line)
+void blkCallPos(const char *pFileName, SDWORD line)
 {
        pCallFileName = pFileName;
        callLine = line;
_______________________________________________
Warzone-dev mailing list
[email protected]
https://mail.gna.org/listinfo/warzone-dev

Reply via email to