void victorywin_Cleanup( void ) { // The individual "s_wonderIcons[i]" items will be deleted through // DeleteHierarchyFromRoot(s_VictoryWindowBlock) in the destructor // of g_victoryWindow. delete [] s_wonderIcons; s_wonderIcons = NULL; if (s_graphList) { s_graphList->Clear(); } if (s_wonderList) { s_wonderList->Clear(); } if (s_scoreList) { s_scoreList->Clear(); } #define mycleanup(mypointer) { delete mypointer; mypointer = NULL; } { mycleanup(s_highScoreWin); mycleanup(s_stringTable); mycleanup(g_victoryWindow); } #undef mycleanup }
AUI_ERRCODE spnewgamerandomcustomscreen_Cleanup() { #define mycleanup(mypointer) if(mypointer) { delete mypointer; mypointer = NULL; }; if ( !s_spNewGameRandomCustomScreen ) return AUI_ERRCODE_OK; g_c3ui->RemoveWindow( s_spNewGameRandomCustomScreen->Id() ); keypress_RemoveHandler(s_spNewGameRandomCustomScreen); for (sint32 i = 0;i < k_NUM_RANDOMCUSTOMBOXES;i++ ) { mycleanup( s_checkBox[i] ); } mycleanup( s_group ); delete s_spNewGameRandomCustomScreen; s_spNewGameRandomCustomScreen = NULL; return AUI_ERRCODE_OK; #undef mycleanup }
//---------------------------------------------------------------------------- // // Name : spnewgamediffscreen_Cleanup // // Description: Release the memory of the screen. // // Parameters : - // // Globals : s_spNewGameDiffScreen // s_barbarianThreat // s_riskBox // s_skillLevel // s_diffListBox // s_riskListBox // // Returns : AUI_ERRCODE : always AUI_ERRCODE_OK // // Remark(s) : - // //---------------------------------------------------------------------------- AUI_ERRCODE spnewgamediffscreen_Cleanup() { if (s_spNewGameDiffScreen) { g_c3ui->RemoveWindow(s_spNewGameDiffScreen->Id()); keypress_RemoveHandler(s_spNewGameDiffScreen); #define mycleanup(mypointer) { delete mypointer; mypointer = NULL; } mycleanup(s_diffListBox); mycleanup(s_riskListBox); mycleanup(s_skillLevel); mycleanup(s_barbarianThreat); mycleanup(s_spNewGameDiffScreen); #undef mycleanup } return AUI_ERRCODE_OK; }
AUI_ERRCODE spnewgamemapsizescreen_Cleanup() { if (s_spNewGameMapSizeScreen) { g_c3ui->RemoveWindow(s_spNewGameMapSizeScreen->Id()); keypress_RemoveHandler(s_spNewGameMapSizeScreen); for (sint32 i = 0; i < k_NUM_MAPSIZEBOXES; ++i) { delete s_checkBox[i]; // NULLing unnecessary: deleting container next } delete [] s_checkBox; s_checkBox = NULL; #define mycleanup(mypointer) { delete mypointer; mypointer = NULL; } mycleanup(s_group); mycleanup(s_spNewGameMapSizeScreen); #undef mycleanup } return AUI_ERRCODE_OK; }
void HighScoreWindowPopup::Cleanup( void ) { if (m_window && g_c3ui) { g_c3ui->RemoveWindow(m_window->Id()); } #define mycleanup(mypointer) { delete mypointer; mypointer = NULL; }; { mycleanup( m_continueButton ); mycleanup( m_creditsButton ); mycleanup( m_quitButton ); mycleanup( m_list ); mycleanup( m_title ); mycleanup( m_highScoreDB ); mycleanup( m_window ); } #undef mycleanup }
AUI_ERRCODE passwordscreen_Cleanup() { #define mycleanup(mypointer) if(mypointer) { delete mypointer; mypointer = NULL; }; if ( !s_passwordScreen ) return AUI_ERRCODE_OK; g_c3ui->RemoveWindow( s_passwordScreen->Id() ); mycleanup( s_askStatic ); mycleanup( s_joinStatic ); mycleanup( s_yesnoSwitchGroup ); mycleanup( s_yesRadio ); mycleanup( s_noRadio ); mycleanup( s_inputStatic ); mycleanup( s_inputTextField ); mycleanup( s_okButton ); mycleanup( s_denyStatic ); mycleanup( s_fullStatic ); mycleanup( s_nolobbyStatic ); mycleanup( s_connectionlostStatic ); mycleanup( s_nodialupStatic ); mycleanup( s_connectionerrStatic ); mycleanup( s_scenarionotfoundStatic ); delete s_passwordScreen; s_passwordScreen = NULL; return AUI_ERRCODE_OK; #undef mycleanup }
void graphicsscreen_Cleanup() { if (g_c3ui && s_graphicsWindow) { g_c3ui->RemoveWindow(s_graphicsWindow->Id()); keypress_RemoveHandler(s_graphicsWindow); } #define mycleanup(mypointer) { delete mypointer; mypointer = NULL; }; mycleanup(s_walk); mycleanup(s_trade); mycleanup(s_wonder); mycleanup(s_cityInfluence); mycleanup(s_grid); mycleanup(s_politicalBorders); mycleanup(s_tradeRoutes); mycleanup(s_cityNames); mycleanup(s_resScreenButton); mycleanup(s_unitSpeed); mycleanup(s_unitSpeedN); mycleanup(s_graphicsWindow); mycleanup(s_armyNames); mycleanup(s_civflags); mycleanup(s_smooth); mycleanup(s_goodAnims); mycleanup(s_cityProd); #undef mycleanup }
//---------------------------------------------------------------------------- // // Name : tileimptracker_Cleanup // // Description: Cleans up the memory that was occupied by the tileimp // tracker window. // // Parameters : - // // Globals : g_tileImpTrackerWindow: The tile improvement tracker window // g_c3ui: The civilization 3 graphical user interface // // Returns : 1 if there is nothing to cleanup, otherwise 0. // // Remark(s) : - // //---------------------------------------------------------------------------- void tileimptracker_Cleanup() { if (g_tileImpTrackerWindow && g_c3ui) { g_c3ui->RemoveWindow(g_tileImpTrackerWindow->Id()); } mycleanup(s_trackerBackground); mycleanup(s_trackerTimeN); mycleanup(s_trackerTimeV); mycleanup(s_trackerMatN); mycleanup(s_trackerMatV); mycleanup(s_trackerFoodN); mycleanup(s_trackerFoodV); mycleanup(s_trackerProductionN); mycleanup(s_trackerProductionV); mycleanup(s_trackerGoldN); mycleanup(s_trackerGoldV); delete g_tileImpTrackerWindow; g_tileImpTrackerWindow = NULL; }
int main (int argc, char *argv[]) { int i,k; int rc; int exit_rc = 0; //long long x; //long long y; float x,y; /* * parse parms and init some stuff. */ setbuf(stdout,NULL); if (argc < 2 || argc > 5) { printf ("Usage: chat_c server_ip_addr [num_rooms] [num_messages] [server_port]\n"); exit(1); } if (!inet_aton(argv[1], &servername.sin_addr.s_addr)) { printf ("Invalid Server IP address\n"); exit(1); } if (argc > 2) nrooms = atoi(argv[2]); if (argc > 3) nmessages = atoi(argv[3]); if (argc > 4) srvport = atoi(argv[4]); #if defined(THREAD0) || defined(THREAD1) { // Set processor affinity unsigned long new_mask; unsigned long cur_mask; unsigned int len = sizeof(new_mask); pid_t pid; pid = getpid(); #ifdef THREAD0 new_mask = 1; #else new_mask = 2; #endif if (sched_getaffinity(pid, len, &cur_mask) < 0) { printf("error: could not get pid %d's affinity.\n", pid); return -1; } printf(" pid %d's old affinity: %08lx\n", pid, cur_mask); if (sched_setaffinity(pid, len, &new_mask)) { printf("error: could not set pid %d's affinity.\n", pid); return -1; } if (sched_getaffinity(pid, len, &cur_mask) < 0) { printf("error: could not get pid %d's affinity.\n", pid); return -1; } printf(" pid %d's new affinity: %08lx\n", pid, cur_mask); } #endif servername.sin_family = AF_INET; servername.sin_port = htons(srvport); /* create the server's listening socket. */ if (exit_rc = myinit()) goto CLI_exit; if (exit_rc = main_client_thread()) goto CLI_exit; for (i = 0 ; i < nrooms ; i++) { for (k = 0 ; k < CLIENTS_PER_ROOM ; k++) { c_msg_snd_total += ti[i*CLIENTS_PER_ROOM+k].msg_snd; c_msg_rcv_total += ti[i*CLIENTS_PER_ROOM+k].msg_rcv; if (cdebug) printf ("%u:%u snd_socket = %u\n", i, k, ti[i*CLIENTS_PER_ROOM+k].snd_socket); if (cdebug) printf ("%u:%u rcv_socket = %u\n", i, k, ti[i*CLIENTS_PER_ROOM+k].rcv_socket); if (cdebug) printf ("%u:%u msg_snd = %u\n", i, k, ti[i*CLIENTS_PER_ROOM+k].msg_snd); if (cdebug) printf ("%u:%u msg_rcv = %u\n", i, k, ti[i*CLIENTS_PER_ROOM+k].msg_rcv); } } printf ("Simulator version : %u.%u.%u\n", 1,0,1 ); printf ("Messages sent : %u\n", c_msg_snd_total ); printf ("Messages received : %u\n", c_msg_rcv_total ); printf ("Total messages : %u\n", c_msg_rcv_total+c_msg_snd_total); printf ("Elapsed time : %u.%0.2u seconds\n", tvr.tv_sec, tvr.tv_usec/1000); x = tvr.tv_sec + (float)tvr.tv_usec/1000000; y = (c_msg_snd_total + c_msg_rcv_total) ; printf ("Average throughput : %10.2f messages per second\n", y/x); if (c_msg_snd_total != nrooms*CLIENTS_PER_ROOM*nmessages) printf ("CLI: expected to snd %u msg, only sent %u msg\n", nrooms*CLIENTS_PER_ROOM*nmessages, c_msg_snd_total); CLI_exit: mycleanup(); exit(exit_rc); }