dos cvs had problem with .lnk file
[fw/sdcc] / src / SDCCset.c
index 007699edf685e210e45f3e71a5189deeb0dd3570..f56b6cf4d1644c046e94c910d716f36b2dffbd1a 100644 (file)
 -------------------------------------------------------------------------*/
 
 #include <stdio.h>
+#if defined(__APPLE__) && defined(__MACH__)
+#include <sys/malloc.h>
+#else
 #include <malloc.h>
+#endif
 #include "newalloc.h"
 #include <assert.h>
 #include "SDCCset.h"
@@ -172,10 +176,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);
@@ -183,6 +190,7 @@ deleteItemIf (set ** sset, int (*cond) (void *, va_list),...)
          continue;
        }
 
+      va_end(ap);
       sp = sp->next;
     }
 }