Typesafe handling of temporary window destroy callback
authorNigel Stewart <nigels.com@gmail.com>
Tue, 30 Dec 2003 02:49:56 +0000 (02:49 +0000)
committerNigel Stewart <nigels.com@gmail.com>
Tue, 30 Dec 2003 02:49:56 +0000 (02:49 +0000)
Move assignment out of while test, scope temporary inside loop
Be explicit about assignment/comparison in if test for gcc peace of mind
suppress gcc -Wall -pendantic "noise"

git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@431 7f0cb862-5218-0410-a997-914c9d46530a

src/freeglut_structure.c

index 8b0a837..cd3a781 100644 (file)
@@ -199,7 +199,7 @@ void fgAddToWindowDestroyList( SFG_Window* window )
      * to ensure that they are no longer called after this point.
      */
     {
-        void *destroy = FETCH_WCB( *window, Destroy );
+        FGCBDestroy destroy = FETCH_WCB( *window, Destroy );
         fgClearCallBacks( window );
         SET_WCB( *window, Destroy, destroy );
     }
@@ -308,7 +308,6 @@ void fgDestroyMenu( SFG_Menu* menu )
 {
     SFG_Window *window;
     SFG_Menu *from;
-    SFG_MenuEntry *entry;
 
     assert( menu );
     freeglut_assert_ready;
@@ -345,8 +344,10 @@ void fgDestroyMenu( SFG_Menu* menu )
      * Now we are pretty sure the menu is not used anywhere
      * and that we can remove all of its entries
      */
-    while( entry = ( SFG_MenuEntry * )menu->Entries.First )
+    while( menu->Entries.First )
     {
+        SFG_MenuEntry *entry = ( SFG_MenuEntry * ) menu->Entries.First;
+
         fgListRemove( &menu->Entries, &entry->Node );
 
         if( entry->Text )
@@ -354,7 +355,6 @@ void fgDestroyMenu( SFG_Menu* menu )
         entry->Text = NULL;
 
         free( entry );
-        entry = NULL;
     }
 
     if( fgStructure.Window == menu->Window )
@@ -582,10 +582,9 @@ void fgListInit(SFG_List *list)
 
 void fgListAppend(SFG_List *list, SFG_Node *node)
 {
-    SFG_Node *ln;
-
-    if ( ln = (SFG_Node *)list->Last )
+    if ( list->Last )
     {
+        SFG_Node *ln = (SFG_Node *) list->Last;
         ln->Next = node;
         node->Prev = ln;
     }
@@ -603,9 +602,9 @@ void fgListRemove(SFG_List *list, SFG_Node *node)
 {
     SFG_Node *ln;
 
-    if( ln = (SFG_Node *)node->Next )
+    if( (ln = (SFG_Node *)node->Next) != NULL )
         ln->Prev = node->Prev;
-    if( ln = (SFG_Node *)node->Prev )
+    if( (ln = (SFG_Node *)node->Prev) != NULL )
         ln->Next = node->Next;
     if( (ln = (SFG_Node *)list->First) == node )
         list->First = node->Next;