From 34290224a4fea01b30fe3c83d3c6d00bd5945acd Mon Sep 17 00:00:00 2001 From: Nigel Stewart Date: Tue, 30 Dec 2003 02:49:56 +0000 Subject: [PATCH] Typesafe handling of temporary window destroy callback 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 | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/freeglut_structure.c b/src/freeglut_structure.c index 8b0a837..cd3a781 100644 --- a/src/freeglut_structure.c +++ b/src/freeglut_structure.c @@ -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; -- 1.7.10.4