summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Appert <dappert>2010-12-11 15:50:03 +0000
committerDamien Appert <dappert>2010-12-11 15:50:03 +0000
commit14ea7720fb2317b41e30f9e66b1732b6dc610fb7 (patch)
tree70c75652fc1ebd5c9f041579538e23842804e9a0
parentbc65b519f8a06758ffdbd305e2f7d90d800992a1 (diff)
download2010-netlemmings-14ea7720fb2317b41e30f9e66b1732b6dc610fb7.tar.gz
2010-netlemmings-14ea7720fb2317b41e30f9e66b1732b6dc610fb7.tar.bz2
2010-netlemmings-14ea7720fb2317b41e30f9e66b1732b6dc610fb7.zip
Memory leak hunting
git-svn-id: file:///var/svn/2010-netlemmings/trunk@192 077b3477-7977-48bd-8428-443f22f7bfda
-rw-r--r--src/netlem.c31
1 files 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<objToRepaintCount;++i) {
res=paintObject(objToRepaint+i, srcRect, tmpSurf);
if ( res!=0 ) {
logs(LOG_DEBUG, "repaint(), paintObject() failed");
- return res;
}
}
res=SDL_BlitSurface(tmpSurf, NULL, dstSurf, &dstRect);
if ( res!=0 ) {
logs2(LOG_DEBUG, "repaint(), SDL_BlitSurface()", SDL_GetError());
- return res;
}
-
- return 0;
+
+ free(objToRepaint);
+ SDL_FreeSurface(tmpSurf);
+ return res;
}
int findAndZSortObjects(gameGraphObjState_t *objectsStat, SDL_Rect *offsetRect, gameGraphObjState_t **objectsFound) {