music.c
changeset 561 87bdb4c81c0b
parent 547 a9a5f18ea123
child 565 64688955a7b2
     1.1 --- a/music.c	Fri Jan 13 02:39:41 2012 -0500
     1.2 +++ b/music.c	Fri Jan 13 03:15:19 2012 -0500
     1.3 @@ -163,7 +163,7 @@
     1.4  
     1.5  static void add_music_decoder(const char *decoder)
     1.6  {
     1.7 -	void *ptr = realloc(music_decoders, (num_decoders + 1) * sizeof (const char **));
     1.8 +	void *ptr = SDL_realloc(music_decoders, (num_decoders + 1) * sizeof (const char **));
     1.9  	if (ptr == NULL) {
    1.10  		return;  /* oh well, go on without it. */
    1.11  	}
    1.12 @@ -520,7 +520,7 @@
    1.13  #ifdef CMD_MUSIC
    1.14  	if ( music_cmd ) {
    1.15  		/* Allocate memory for the music structure */
    1.16 -		music = (Mix_Music *)malloc(sizeof(Mix_Music));
    1.17 +		music = (Mix_Music *)SDL_malloc(sizeof(Mix_Music));
    1.18  		if ( music == NULL ) {
    1.19  			Mix_SetError("Out of memory");
    1.20  			return(NULL);
    1.21 @@ -529,7 +529,7 @@
    1.22  		music->type = MUS_CMD;
    1.23  		music->data.cmd = MusicCMD_LoadSong(music_cmd, file);
    1.24  		if ( music->data.cmd == NULL ) {
    1.25 -			free(music);
    1.26 +			SDL_free(music);
    1.27  			music == NULL;
    1.28  		}
    1.29  		return music;
    1.30 @@ -606,7 +606,7 @@
    1.31  	}
    1.32  
    1.33  	/* Allocate memory for the music structure */
    1.34 -	music = (Mix_Music *)malloc(sizeof(Mix_Music));
    1.35 +	music = (Mix_Music *)SDL_malloc(sizeof(Mix_Music));
    1.36  	if (music == NULL ) {
    1.37  		Mix_SetError("Out of memory");
    1.38  		return NULL;
    1.39 @@ -745,7 +745,7 @@
    1.40  
    1.41  
    1.42  	if (music->error) {
    1.43 -		free(music);
    1.44 +		SDL_free(music);
    1.45  		music=NULL;
    1.46  	}
    1.47  	return(music);
    1.48 @@ -838,7 +838,7 @@
    1.49  		}
    1.50  
    1.51      skip:
    1.52 -		free(music);
    1.53 +		SDL_free(music);
    1.54  	}
    1.55  }
    1.56  
    1.57 @@ -1481,11 +1481,11 @@
    1.58  {
    1.59  	Mix_HaltMusic();
    1.60  	if ( music_cmd ) {
    1.61 -		free(music_cmd);
    1.62 +		SDL_free(music_cmd);
    1.63  		music_cmd = NULL;
    1.64  	}
    1.65  	if ( command ) {
    1.66 -		music_cmd = (char *)malloc(strlen(command)+1);
    1.67 +		music_cmd = (char *)SDL_malloc(strlen(command)+1);
    1.68  		if ( music_cmd == NULL ) {
    1.69  			return(-1);
    1.70  		}
    1.71 @@ -1527,7 +1527,7 @@
    1.72  #endif
    1.73  
    1.74  	/* rcg06042009 report available decoders at runtime. */
    1.75 -	free(music_decoders);
    1.76 +	SDL_free(music_decoders);
    1.77  	music_decoders = NULL;
    1.78  	num_decoders = 0;
    1.79  
    1.80 @@ -1538,12 +1538,12 @@
    1.81  {
    1.82  #ifdef MID_MUSIC
    1.83  	if (soundfont_paths) {
    1.84 -		free(soundfont_paths);
    1.85 +		SDL_free(soundfont_paths);
    1.86  		soundfont_paths = NULL;
    1.87  	}
    1.88  
    1.89  	if (paths) {
    1.90 -		if (!(soundfont_paths = strdup(paths))) {
    1.91 +		if (!(soundfont_paths = SDL_strdup(paths))) {
    1.92  			Mix_SetError("Insufficient memory to set SoundFonts");
    1.93  			return 0;
    1.94  		}
    1.95 @@ -1574,7 +1574,7 @@
    1.96  		return 0;
    1.97  	}
    1.98  
    1.99 -	if (!(paths = strdup(cpaths))) {
   1.100 +	if (!(paths = SDL_strdup(cpaths))) {
   1.101  		Mix_SetError("Insufficient memory to iterate over SoundFonts");
   1.102  		return 0;
   1.103  	}
   1.104 @@ -1587,12 +1587,12 @@
   1.105  	for (path = strtok_r(paths, ":;", &context); path; path = strtok_r(NULL, ":;", &context)) {
   1.106  #endif
   1.107  		if (!function(path, data)) {
   1.108 -			free(paths);
   1.109 +			SDL_free(paths);
   1.110  			return 0;
   1.111  		}
   1.112  	}
   1.113  
   1.114 -	free(paths);
   1.115 +	SDL_free(paths);
   1.116  	return 1;
   1.117  }
   1.118  #endif