mixer.c
changeset 561 87bdb4c81c0b
parent 560 0fc8dffb86c5
child 562 4129f7c1c68f
     1.1 --- a/mixer.c	Fri Jan 13 02:39:41 2012 -0500
     1.2 +++ b/mixer.c	Fri Jan 13 03:15:19 2012 -0500
     1.3 @@ -126,7 +126,7 @@
     1.4  
     1.5  static void add_chunk_decoder(const char *decoder)
     1.6  {
     1.7 -	void *ptr = realloc(chunk_decoders, (num_decoders + 1) * sizeof (const char **));
     1.8 +	void *ptr = SDL_realloc(chunk_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 @@ -227,7 +227,7 @@
    1.13  #endif
    1.14  #ifdef MID_MUSIC
    1.15  	if (soundfont_paths) {
    1.16 -		free(soundfont_paths);
    1.17 +		SDL_free(soundfont_paths);
    1.18  	}
    1.19  #endif
    1.20  	initialized = 0;
    1.21 @@ -263,11 +263,11 @@
    1.22  	if (e != NULL) {    /* are there any registered effects? */
    1.23  		/* if this is the postmix, we can just overwrite the original. */
    1.24  		if (!posteffect) {
    1.25 -			buf = malloc(len);
    1.26 +			buf = SDL_malloc(len);
    1.27  			if (buf == NULL) {
    1.28  				return(snd);
    1.29  			}
    1.30 -		    memcpy(buf, snd, len);
    1.31 +			memcpy(buf, snd, len);
    1.32  		}
    1.33  
    1.34  		for (; e != NULL; e = e->next) {
    1.35 @@ -277,7 +277,7 @@
    1.36  		}
    1.37  	}
    1.38  
    1.39 -	/* be sure to free() the return value if != snd ... */
    1.40 +	/* be sure to SDL_free() the return value if != snd ... */
    1.41  	return(buf);
    1.42  }
    1.43  
    1.44 @@ -344,7 +344,7 @@
    1.45  					mix_input = Mix_DoEffects(i, mix_channel[i].samples, mixable);
    1.46  					SDL_MixAudio(stream+index,mix_input,mixable,volume);
    1.47  					if (mix_input != mix_channel[i].samples)
    1.48 -						free(mix_input);
    1.49 +						SDL_free(mix_input);
    1.50  
    1.51  					mix_channel[i].samples += mixable;
    1.52  					mix_channel[i].playing -= mixable;
    1.53 @@ -368,7 +368,7 @@
    1.54  					mix_input = Mix_DoEffects(i, mix_channel[i].chunk->abuf, remaining);
    1.55  					SDL_MixAudio(stream+index, mix_input, remaining, volume);
    1.56  					if (mix_input != mix_channel[i].chunk->abuf)
    1.57 -						free(mix_input);
    1.58 +						SDL_free(mix_input);
    1.59  
    1.60  					--mix_channel[i].looping;
    1.61  					mix_channel[i].samples = mix_channel[i].chunk->abuf + remaining;
    1.62 @@ -443,7 +443,7 @@
    1.63  	}
    1.64  
    1.65  	num_channels = MIX_CHANNELS;
    1.66 -	mix_channel = (struct _Mix_Channel *) malloc(num_channels * sizeof(struct _Mix_Channel));
    1.67 +	mix_channel = (struct _Mix_Channel *) SDL_malloc(num_channels * sizeof(struct _Mix_Channel));
    1.68  
    1.69  	/* Clear out the audio channels */
    1.70  	for ( i=0; i<num_channels; ++i ) {
    1.71 @@ -497,7 +497,7 @@
    1.72  		}
    1.73  	}
    1.74  	SDL_LockAudio();
    1.75 -	mix_channel = (struct _Mix_Channel *) realloc(mix_channel, numchans * sizeof(struct _Mix_Channel));
    1.76 +	mix_channel = (struct _Mix_Channel *) SDL_realloc(mix_channel, numchans * sizeof(struct _Mix_Channel));
    1.77  	if ( numchans > num_channels ) {
    1.78  		/* Initialize the new channels */
    1.79  		int i;
    1.80 @@ -568,7 +568,7 @@
    1.81  	}
    1.82  
    1.83  	/* Allocate the chunk memory */
    1.84 -	chunk = (Mix_Chunk *)malloc(sizeof(Mix_Chunk));
    1.85 +	chunk = (Mix_Chunk *)SDL_malloc(sizeof(Mix_Chunk));
    1.86  	if ( chunk == NULL ) {
    1.87  		SDL_SetError("Out of memory");
    1.88  		if ( freesrc ) {
    1.89 @@ -613,7 +613,7 @@
    1.90  			return(0);			
    1.91  	}
    1.92  	if ( !loaded ) {
    1.93 -		free(chunk);
    1.94 +		SDL_free(chunk);
    1.95  		if ( freesrc ) {
    1.96  			SDL_RWclose(src);
    1.97  		}
    1.98 @@ -632,26 +632,26 @@
    1.99  		if ( SDL_BuildAudioCVT(&wavecvt,
   1.100  				wavespec.format, wavespec.channels, wavespec.freq,
   1.101  				mixer.format, mixer.channels, mixer.freq) < 0 ) {
   1.102 -			SDL_FreeWAV(chunk->abuf);
   1.103 -			free(chunk);
   1.104 +			SDL_free(chunk->abuf);
   1.105 +			SDL_free(chunk);
   1.106  			return(NULL);
   1.107  		}
   1.108  		samplesize = ((wavespec.format & 0xFF)/8)*wavespec.channels;
   1.109  		wavecvt.len = chunk->alen & ~(samplesize-1);
   1.110 -		wavecvt.buf = (Uint8 *)calloc(1, wavecvt.len*wavecvt.len_mult);
   1.111 +		wavecvt.buf = (Uint8 *)SDL_calloc(1, wavecvt.len*wavecvt.len_mult);
   1.112  		if ( wavecvt.buf == NULL ) {
   1.113  			SDL_SetError("Out of memory");
   1.114 -			SDL_FreeWAV(chunk->abuf);
   1.115 -			free(chunk);
   1.116 +			SDL_free(chunk->abuf);
   1.117 +			SDL_free(chunk);
   1.118  			return(NULL);
   1.119  		}
   1.120  		memcpy(wavecvt.buf, chunk->abuf, chunk->alen);
   1.121 -		SDL_FreeWAV(chunk->abuf);
   1.122 +		SDL_free(chunk->abuf);
   1.123  
   1.124  		/* Run the audio converter */
   1.125  		if ( SDL_ConvertAudio(&wavecvt) < 0 ) {
   1.126 -			free(wavecvt.buf);
   1.127 -			free(chunk);
   1.128 +			SDL_free(wavecvt.buf);
   1.129 +			SDL_free(chunk);
   1.130  			return(NULL);
   1.131  		}
   1.132  	}
   1.133 @@ -677,7 +677,7 @@
   1.134  	}
   1.135  
   1.136  	/* Allocate the chunk memory */
   1.137 -	chunk = (Mix_Chunk *)calloc(1,sizeof(Mix_Chunk));
   1.138 +	chunk = (Mix_Chunk *)SDL_calloc(1,sizeof(Mix_Chunk));
   1.139  	if ( chunk == NULL ) {
   1.140  		SDL_SetError("Out of memory");
   1.141  		return(NULL);
   1.142 @@ -711,7 +711,7 @@
   1.143  	}
   1.144  
   1.145  	/* Allocate the chunk memory */
   1.146 -	chunk = (Mix_Chunk *)malloc(sizeof(Mix_Chunk));
   1.147 +	chunk = (Mix_Chunk *)SDL_malloc(sizeof(Mix_Chunk));
   1.148  	if ( chunk == NULL ) {
   1.149  		SDL_SetError("Out of memory");
   1.150  		return(NULL);
   1.151 @@ -746,9 +746,9 @@
   1.152  		SDL_UnlockAudio();
   1.153  		/* Actually free the chunk */
   1.154  		if ( chunk->allocated ) {
   1.155 -			free(chunk->abuf);
   1.156 +			SDL_free(chunk->abuf);
   1.157  		}
   1.158 -		free(chunk);
   1.159 +		SDL_free(chunk);
   1.160  	}
   1.161  }
   1.162  
   1.163 @@ -1135,11 +1135,11 @@
   1.164  			Mix_HaltChannel(-1);
   1.165  			_Mix_DeinitEffects();
   1.166  			SDL_CloseAudio();
   1.167 -			free(mix_channel);
   1.168 +			SDL_free(mix_channel);
   1.169  			mix_channel = NULL;
   1.170  
   1.171  			/* rcg06042009 report available decoders at runtime. */
   1.172 -			free(chunk_decoders);
   1.173 +			SDL_free(chunk_decoders);
   1.174  			chunk_decoders = NULL;
   1.175  			num_decoders = 0;
   1.176  		}
   1.177 @@ -1311,7 +1311,7 @@
   1.178  		return(0);
   1.179  	}
   1.180  
   1.181 -	new_e = malloc(sizeof (effect_info));
   1.182 +	new_e = SDL_malloc(sizeof (effect_info));
   1.183  	if (new_e == NULL) {
   1.184  		Mix_SetError("Out of memory");
   1.185  		return(0);
   1.186 @@ -1358,7 +1358,7 @@
   1.187  			if (cur->done_callback != NULL) {
   1.188  				cur->done_callback(channel, cur->udata);
   1.189  			}
   1.190 -			free(cur);
   1.191 +			SDL_free(cur);
   1.192  
   1.193  			if (prev == NULL) {   /* removing first item of list? */
   1.194  				*e = next;
   1.195 @@ -1391,7 +1391,7 @@
   1.196  		if (cur->done_callback != NULL) {
   1.197  			cur->done_callback(channel, cur->udata);
   1.198  		}
   1.199 -		free(cur);
   1.200 +		SDL_free(cur);
   1.201  	}
   1.202  	*e = NULL;
   1.203