From 14ea7720fb2317b41e30f9e66b1732b6dc610fb7 Mon Sep 17 00:00:00 2001 From: Damien Appert Date: Sat, 11 Dec 2010 15:50:03 +0000 Subject: Memory leak hunting git-svn-id: file:///var/svn/2010-netlemmings/trunk@192 077b3477-7977-48bd-8428-443f22f7bfda --- src/netlem.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/netlem.c b/src/netlem.c index 9628050..b47a0eb 100644 --- a/src/netlem.c +++ b/src/netlem.c @@ -199,8 +199,25 @@ int main(int argc, char **argv) { // Close communcation with the server, stop threads, close logs and go out SDLNet_TCP_Close(client.sockClient); + + SDL_FreeSurface(gGraph.surfaces.screen); + SDL_FreeSurface(gGraph.surfaces.terrain); + SDL_FreeSurface(gGraph.surfaces.stencil); + + // Pour tout les objectsSurf + //SDL_FreeSurface(gGraph->surfaces.objectsSurf[i]); + + SDL_WaitThread(networkReadThread, &result); - sprintf(logMsg, "TimeSync thread terminated with code %i", result); + sprintf(logMsg, "networkReadThread terminated with code %i", result); + + SDL_SemPost(semLoadLevel); + SDL_WaitThread(loadLevelThread, &result); + sprintf(logMsg, "loadLevelThread terminated with code %i", result); + + SDL_DestroySemaphore(semGameStart); + SDL_DestroySemaphore(semLoadLevel); + logs(LOG_DEBUG, logMsg); closeLog(); @@ -376,7 +393,6 @@ int loadLevel(struct _loadLevelProc_args *args) { *(args->loadProgress)=1; // Loading lvl ini file - //FIXME : dynamic ! len=strlen(PATH_LEVEL)+strlen("1_orig")+strlen("lvl0003")+strlen("//.ini")+1; filepath=malloc(sizeof(char)*len); snprintf(filepath, len, "%s/%s/%s.ini", PATH_LEVEL, "1_orig", "lvl0003"); @@ -582,6 +598,7 @@ int repaint(gameGraphSurfaces_t *srcSurfs, SDL_Rect *srcRect, SDL_Surface *dstSu SDL_Surface *tmpSurf; tmpSurf=createSurface(srcRect->w, srcRect->h); + if (tmpSurf==NULL) { logs(LOG_ERROR, "repain(), createSurface() has failed"); return 1; @@ -593,31 +610,29 @@ int repaint(gameGraphSurfaces_t *srcSurfs, SDL_Rect *srcRect, SDL_Surface *dstSu res=paintObject(objToRepaint+i, srcRect, tmpSurf); if ( res!=0 ) { logs(LOG_DEBUG, "repaint(), paintObject() failed"); - return res; } } res=SDL_BlitSurface(srcSurfs->terrain, srcRect, tmpSurf, NULL); if ( res!=0 ) { logs2(LOG_DEBUG, "repaint(), SDL_BlitSurface()", SDL_GetError()); - return res; } for(;i