[sdlsound] Mechanism of getting buffer seperate from Sound_Sample?

Ryan C. Gordon icculus at clutteredmind.org
Tue Jan 14 16:03:15 EST 2003

> Say, you're decoding an awful lot of raw data with Sound_DecodeAll, and
> want to pass this data to a function that doesn't know how to free
> Sound_Sample structures.  In fact, it doesn't know SDL_sound exists at
> all, and expects to be able to free this block with free() when it's
> done.  How can one free the SDL_sound structure, without freeing the
> buffer?  I've been setting sample->buffer to NULL before freeing it, and
> that seems to work, but I suspect that's extremely bad form...

It is bad form, but (at least currently) it works, since we use malloc
to allocate the buffer. Don't know a good solution. If you're wrapping the
buffer in a memory RWops, you can always use the trick we use for SMPEG
(The Reference Counter RWops, look at extra_rwops.h in SDL_sound's


More information about the sdlsound mailing list