[Change] Useing ldata_rwops where applicable.
[Fix] Memleak.
This commit is contained in:
		
							parent
							
								
									7c81351fda
								
							
						
					
					
						commit
						b9c52585e8
					
				| @ -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)); | ||||
| 
 | ||||
|  | ||||
| @ -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()); | ||||
|  | ||||
| @ -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; | ||||
| 
 | ||||
|  | ||||
| @ -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; | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Allanis
						Allanis