SDL_RWops memory ownership question

If I have a pointer to some dynamically allocated memory and use
SDL_RWFromMem to make it into an RWops as shown in the following
psuedo-code:

SDL_RWops * func()
{
SDL_RWops *rw;
//code to allocate buffer and load file from archive
rw = SDL_RWFromMem(buffer, size);
delete []buffer; //here or later?
return rw;
}

After using rw I know to call SDL_FreeRW(rw) but I’m not sure if it’s ok
to free buffer before the RW is free or if I should wait until after or
if SDL_FreeRW takes care of freeing that memory.

I took a quick glance at the source and it looks as if RWops’ simply
contain a pointer to the space in buffer, in which case I would need to
free buffer myself after the rwops is used. If this is the case would
the best option for my needs (a function that returns an rwops) be
simply writing my own special version of SDL_RWFromMem?