Remove all references to the GC library, replacing GC_malloc
[fw/sdcc] / src / SDCCset.c
index a4844a3779502a8fb4052da908fb5ec0c27cbb3c..f1f039d0386e05026bb8d6e9531f990e6c122e9d 100644 (file)
@@ -23,6 +23,7 @@
 -------------------------------------------------------------------------*/
 
 #include <stdio.h>
+#include <malloc.h>
 #include <assert.h>
 #include "SDCCset.h"
 
@@ -33,7 +34,11 @@ set *newSet  ()
 {
   set *lp ;
 
-  ALLOC(lp,sizeof(set)) ;
+  lp = calloc(1, sizeof(set));
+  if (lp == 0) {
+       fprintf(stderr, "out of virtual memory: %s\n", __FILE__);
+       exit(1);
+  }
 
   lp->item = lp->curr= lp->next = NULL;
   return lp;
@@ -402,10 +407,11 @@ int applyToSet ( set *list , int (*somefunc)(void *, va_list ), ...)
     va_list ap;
     int rvalue = 0 ;
     
-    va_start(ap,somefunc);
-    for (lp = list ; lp ; lp = lp->next ) 
-       rvalue += (*somefunc)(lp->item,ap) ;
-    va_end(ap);
+    for (lp = list ; lp ; lp = lp->next ) {
+         va_start(ap,somefunc);
+         rvalue += (*somefunc)(lp->item,ap) ;
+         va_end(ap);
+    }
     return rvalue;
 }
 
@@ -419,11 +425,13 @@ int applyToSetFTrue ( set *list , int (*somefunc)(void *, va_list ), ...)
     va_list ap;
     int rvalue = 0 ;
     
-    va_start(ap,somefunc);
-    for (lp = list ; lp ; lp = lp->next ) 
-       if (rvalue += (*somefunc)(lp->item,ap))
-           break;
-    va_end(ap);
+    for (lp = list ; lp ; lp = lp->next ) {
+         va_start(ap,somefunc);
+         rvalue += (*somefunc)(lp->item,ap);
+         va_end(ap);
+         if (rvalue)
+               break;
+    }
     return rvalue;
 }
 
@@ -495,6 +503,6 @@ void setToNull (void **item )
 
     if (! *item )
        return ;
-    GC_free(*item);  
+    free(*item);  
     *item = NULL ;
 }