comparison src/audio/SDL_audiocvt.c @ 2880:3c2f56e433a8

Allocate SDL_AudioCVT::coeff before using it. FIXME: this is a memory leak. We don't have an SDL_FreeAudioCVT() yet.
author Ryan C. Gordon <icculus@icculus.org>
date Fri, 19 Dec 2008 08:30:26 +0000
parents 3ff86c46d324
children c8d203ef4335
comparison
equal deleted inserted replaced
2879:3ff86c46d324 2880:3c2f56e433a8
1680 for( i = 0; i <= m; ++i ) { \ 1680 for( i = 0; i <= m; ++i ) { \
1681 dst[i] = fix(fSinc[i] * norm_fact); \ 1681 dst[i] = fix(fSinc[i] * norm_fact); \
1682 } \ 1682 } \
1683 } 1683 }
1684 1684
1685 /* !!! FIXME: this memory leaks. */
1686 cvt->coeff = (Uint8 *) SDL_malloc((SDL_AUDIO_BITSIZE(format) / 8) * m);
1687 if (cvt->coeff == NULL) {
1688 return -1;
1689 }
1690
1685 /* If we're using floating point, we only need to normalize */ 1691 /* If we're using floating point, we only need to normalize */
1686 if (SDL_AUDIO_ISFLOAT(format) && SDL_AUDIO_BITSIZE(format) == 32) { 1692 if (SDL_AUDIO_ISFLOAT(format) && SDL_AUDIO_BITSIZE(format) == 32) {
1687 float *fDest = (float *) cvt->coeff; 1693 float *fDest = (float *) cvt->coeff;
1688 for (i = 0; i <= m; ++i) { 1694 for (i = 0; i <= m; ++i) {
1689 fDest[i] = fSinc[i] * norm_fact; 1695 fDest[i] = fSinc[i] * norm_fact;