Added printf_fast to library
[fw/sdcc] / src / SDCCset.c
index 24e936aa440381f28daed9610ebfcd484ffd003b..07ab964ae94ea65726ee37fbfeebcded4ecb1310 100644 (file)
@@ -23,6 +23,7 @@
 -------------------------------------------------------------------------*/
 
 #include <stdio.h>
+#include <malloc.h>
 #include "newalloc.h"
 #include <assert.h>
 #include "SDCCset.h"
@@ -171,10 +172,13 @@ deleteItemIf (set ** sset, int (*cond) (void *, va_list),...)
   set *sp = *sset;
   va_list ap;
 
-  va_start (ap, cond);
-
   while (sp)
     {
+      // On the x86 va_list is just a pointer, so due to pass by value
+      // ap is not mofified by the called function.  On the PPC va_list
+      // is a pointer to a structure, so ap is modified.  Re-init each time.
+      va_start (ap, cond);
+
       if ((*cond) (sp->item, ap))
        {
          deleteSetItem (sset, sp->item);
@@ -182,6 +186,7 @@ deleteItemIf (set ** sset, int (*cond) (void *, va_list),...)
          continue;
        }
 
+      va_end(ap);
       sp = sp->next;
     }
 }