diff --git a/src/fleet.c b/src/fleet.c index 575bfd0..6fa0f97 100644 --- a/src/fleet.c +++ b/src/fleet.c @@ -247,6 +247,7 @@ static int fleet_parseGroup(FleetGroup* fltgrp, xmlNodePtr parent) { continue; } fltgrp->chance[fltgrp->nfleets-1] = CLAMP(0, 100, atoi(buf)); + free(buf); } } while(xml_nextNode(node)); diff --git a/src/opengl.c b/src/opengl.c index dea3609..a2b24b2 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -503,18 +503,15 @@ static glTexture* gl_loadNewImage(const char* path, const unsigned int flags) { SDL_Surface* tmp, *surface; glTexture* t; uint8_t* trans; - uint32_t filesize; - char* buf; + SDL_RWops* rw; /* Load from packfile. */ - buf = ldata_read(path, &filesize); - if(buf == NULL) { + rw = ldata_rwops(path); + if(rw == NULL) { ERR("Loading surface from ldata."); return NULL; } - SDL_RWops* rw = SDL_RWFromMem(buf, filesize); tmp = IMG_Load_RW(rw, 1); - free(buf); if(tmp == 0) { ERR("'%s' could not be opened: %s", path, IMG_GetError()); diff --git a/src/pack.c b/src/pack.c index 67a4ecc..865e0e3 100644 --- a/src/pack.c +++ b/src/pack.c @@ -845,7 +845,6 @@ static int packrw_close(SDL_RWops* rw) { * @param packfile Packfile to create rwops from. * @return rwops created from packfile. */ - static SDL_RWops* pack_rwopsRaw(Packfile_t* packfile) { SDL_RWops* rw; diff --git a/src/sound.c b/src/sound.c index 3cadaa6..06b0551 100644 --- a/src/sound.c +++ b/src/sound.c @@ -510,16 +510,13 @@ int sound_volume(const double vol) { * @sa sound_makeList */ static Mix_Chunk* sound_load(const char* filename) { - void* wavdata; - unsigned int size; SDL_RWops* rw; Mix_Chunk* buffer; if(sound_disabled) return NULL; /* Get the file data buffer from the packfile. */ - wavdata = ldata_read(filename, &size); - rw = SDL_RWFromMem(wavdata, size); + rw = ldata_rwops(filename); /* Bind to OpenAL buffer. */ buffer = Mix_LoadWAV_RW(rw, 1); @@ -527,8 +524,6 @@ static Mix_Chunk* sound_load(const char* filename) { if(buffer == NULL) DEBUG("Unable to load sound '%s' : %s", filename, Mix_GetError()); - /* Finish up. */ - free(wavdata); return buffer; }