[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; |         continue; | ||||||
|       } |       } | ||||||
|       fltgrp->chance[fltgrp->nfleets-1] = CLAMP(0, 100, atoi(buf)); |       fltgrp->chance[fltgrp->nfleets-1] = CLAMP(0, 100, atoi(buf)); | ||||||
|  |       free(buf); | ||||||
|     } |     } | ||||||
|   } while(xml_nextNode(node)); |   } while(xml_nextNode(node)); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -503,18 +503,15 @@ static glTexture* gl_loadNewImage(const char* path, const unsigned int flags) { | |||||||
|   SDL_Surface* tmp, *surface; |   SDL_Surface* tmp, *surface; | ||||||
|   glTexture* t; |   glTexture* t; | ||||||
|   uint8_t* trans; |   uint8_t* trans; | ||||||
|   uint32_t filesize; |   SDL_RWops* rw; | ||||||
|   char* buf; |  | ||||||
| 
 | 
 | ||||||
|   /* Load from packfile. */ |   /* Load from packfile. */ | ||||||
|   buf = ldata_read(path, &filesize); |   rw = ldata_rwops(path); | ||||||
|   if(buf == NULL) { |   if(rw == NULL) { | ||||||
|     ERR("Loading surface from ldata."); |     ERR("Loading surface from ldata."); | ||||||
|     return NULL; |     return NULL; | ||||||
|   } |   } | ||||||
|   SDL_RWops* rw = SDL_RWFromMem(buf, filesize); |  | ||||||
|   tmp = IMG_Load_RW(rw, 1); |   tmp = IMG_Load_RW(rw, 1); | ||||||
|   free(buf); |  | ||||||
| 
 | 
 | ||||||
|   if(tmp == 0) { |   if(tmp == 0) { | ||||||
|     ERR("'%s' could not be opened: %s", path, IMG_GetError()); |     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. |  *    @param packfile Packfile to create rwops from. | ||||||
|  *    @return rwops created from packfile. |  *    @return rwops created from packfile. | ||||||
|  */ |  */ | ||||||
| 
 |  | ||||||
| static SDL_RWops* pack_rwopsRaw(Packfile_t* packfile) { | static SDL_RWops* pack_rwopsRaw(Packfile_t* packfile) { | ||||||
|   SDL_RWops* rw; |   SDL_RWops* rw; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -510,16 +510,13 @@ int sound_volume(const double vol) { | |||||||
|  * @sa sound_makeList |  * @sa sound_makeList | ||||||
|  */ |  */ | ||||||
| static Mix_Chunk* sound_load(const char* filename) { | static Mix_Chunk* sound_load(const char* filename) { | ||||||
|   void* wavdata; |  | ||||||
|   unsigned int size; |  | ||||||
|   SDL_RWops* rw; |   SDL_RWops* rw; | ||||||
|   Mix_Chunk* buffer; |   Mix_Chunk* buffer; | ||||||
| 
 | 
 | ||||||
|   if(sound_disabled) return NULL; |   if(sound_disabled) return NULL; | ||||||
| 
 | 
 | ||||||
|   /* Get the file data buffer from the packfile. */ |   /* Get the file data buffer from the packfile. */ | ||||||
|   wavdata = ldata_read(filename, &size); |   rw = ldata_rwops(filename); | ||||||
|   rw = SDL_RWFromMem(wavdata, size); |  | ||||||
| 
 | 
 | ||||||
|   /* Bind to OpenAL buffer. */ |   /* Bind to OpenAL buffer. */ | ||||||
|   buffer = Mix_LoadWAV_RW(rw, 1); |   buffer = Mix_LoadWAV_RW(rw, 1); | ||||||
| @ -527,8 +524,6 @@ static Mix_Chunk* sound_load(const char* filename) { | |||||||
|   if(buffer == NULL) |   if(buffer == NULL) | ||||||
|     DEBUG("Unable to load sound '%s' : %s", filename, Mix_GetError()); |     DEBUG("Unable to load sound '%s' : %s", filename, Mix_GetError()); | ||||||
| 
 | 
 | ||||||
|   /* Finish up. */ |  | ||||||
|   free(wavdata); |  | ||||||
|   return buffer; |   return buffer; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Allanis
						Allanis