Commits

Anonymous committed 8215d8f

ooo340fixes: #i117780# use rtl allocator

Comments (0)

Files changed (1)

vcl/source/fontsubset/list.c

 /*|  Author: Alexander Gelfenbain                       |*/
 /*[]---------------------------------------------------[]*/
 
-#include <stdlib.h>
+#include <rtl/alloc.h>
 
 #if OSL_DEBUG_LEVEL == 0
 #  ifndef NDEBUG
 
 #include <assert.h>
 
-#ifdef MALLOC_TRACE
-#include <stdio.h>
-#include </usr/local/include/malloc.h>
-#endif
 /* #define TEST */
 #include "list.h"
 
 
 static lnode *newNode(void *el)
 {
-    lnode *ptr = malloc(sizeof(lnode));
+    lnode *ptr = rtl_allocateMemory(sizeof(lnode));
     assert(ptr != 0);
 
     ptr->value = el;
 /*- public methods  */
 list listNewEmpty(void)                           /*- default ctor */
 {
-    list this = malloc(sizeof(struct _list));
+    list this = rtl_allocateMemory(sizeof(struct _list));
     assert(this != 0);
 
     this->aCount = 0;
     list this;
     assert(l != 0);
 
-    this = malloc(sizeof(struct _list));
+    this = rtl_allocateMemory(sizeof(struct _list));
     assert(this != 0);
 
     ptr = l->head;
 {
     assert(this != 0);
     listClear(this);
-    free(this);
+    rtl_freeMemory(this);
 }
 
 void listSetElementDtor(list this, list_destructor f)
 
     if (this->eDtor) this->eDtor(this->cptr->value);        /* call the dtor callback */
 
-    free(this->cptr);
+    rtl_freeMemory(this->cptr);
     this->aCount--;
     this->cptr = ptr;
     return this;
     while (node) {
         ptr = node->next;
         if (this->eDtor) this->eDtor(node->value);           /* call the dtor callback */
-        free(node);
+        rtl_freeMemory(node);
         this->aCount--;
         node = ptr;
     }
 void edtor(void *ptr)
 {
     printf("element dtor: 0x%08x\n", ptr);
-    free(ptr);
+    rtl_freeMemory(ptr);
 }
 
 int main()
     char *ptr;
     int i;
 
-#ifdef MALLOC_TRACE
-    mal_leaktrace(1);
-    mal_debug(2);
-#endif
-
     l1 = listNewEmpty();
     printstat(l1);
 
     listSetElementDtor(l1, edtor);
 
     for(i=0; i<10; i++) {
-        ptr = malloc(20);
+        ptr = rtl_allocateMemory(20);
         snprintf(ptr, 20, "element # %d", i);
         listAppend(l1, ptr);
     }
     listDispose(l1);
     listDispose(l2);
 
-#ifdef MALLOC_TRACE
-    mal_dumpleaktrace(stdout);
-#endif
-
 
     return 0;
 }