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: https://svn.code.sf.net/p/freeglut/code/trunk@431 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
nigels 2003-12-30 02:49:56 +00:00
parent 54ba1965ee
commit 2ed416a592

View File

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