Fixed up va_args for ppc
authormichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 5 May 2001 21:46:11 +0000 (21:46 +0000)
committermichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 5 May 2001 21:46:11 +0000 (21:46 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@780 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCset.c

index 007699edf685e210e45f3e71a5189deeb0dd3570..07ab964ae94ea65726ee37fbfeebcded4ecb1310 100644 (file)
@@ -172,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);
@@ -183,6 +186,7 @@ deleteItemIf (set ** sset, int (*cond) (void *, va_list),...)
          continue;
        }
 
+      va_end(ap);
       sp = sp->next;
     }
 }