Remove all references to the GC library, replacing GC_malloc
[fw/sdcc] / src / SDCCset.c
index 049a3e3834f1254e56c096bf7dd85db56e50a00d..f1f039d0386e05026bb8d6e9531f990e6c122e9d 100644 (file)
     what you give them.   Help stamp out software-hoarding!  
 -------------------------------------------------------------------------*/
 
-#include "common.h"
+#include <stdio.h>
+#include <malloc.h>
+#include <assert.h>
+#include "SDCCset.h"
 
 /*-----------------------------------------------------------------*/
 /* newSet - will allocate & return a new set entry             */
@@ -31,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;
@@ -400,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;
 }
 
@@ -417,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;
 }
 
@@ -493,6 +503,6 @@ void setToNull (void **item )
 
     if (! *item )
        return ;
-    GC_free(*item);  
+    free(*item);  
     *item = NULL ;
 }