[vorbis-dev] vorbisfile close and memory callbacks

Monty xiphmont at xiph.org
Sun Oct 22 21:30:49 PDT 2000



> it might be a good idea to remove close_func from the vorbisfile callbacks,
> or do a null check if the user doesnt want vorbis to close the file?
> We open the file ourselves, so it seems strange that vorbisfile closes it
> without permission :)

See previous discussion of this in the archive.  Actually, it isn't quite fair 
for me to say that, it'll likely be hard to find... hmm... need to implement 
search.

Summary:

When you hand a FILE* (or someother handle) to vorbisfile, vorbisfile from
there on owns that resource, period. You are not to interfere with that
resource whatsoever as this could invalidate [normally sound] logic within
vorbisfile, causing it to implode (or worse, corrupt data, the ticking time
bomb danger of any C program).  Therefore, vorbisfile also takes the
responsibility of closing out the handle.

This is sound OO reasoning and documented (although said document is 'in
progress' from Kim.  Kim can we get that puppy into CVS ASAP, finished or no?)

>otherwise it will crash trying to close a previously closed and freed handle
>(my streamer logic has always opened and closed the file itself, or it may
>want to keep the file open!).

Vorbisfile owns the resource.  It may even decide to hold the file open for its
own purposes past an apparent 'close'; this is part of the design criteria of 
vorbisfile.

>Another idea i thought might be nice is memory allocation callbacks?  I and
>many other projects probably use their own memory manager for debugging
>purposes etc, and because ogg/vorbis allocates memory with stdlib it makes
>it hard to track memory..  (on consoles this is especially important)

I'm a bit worried about different parties eventually asking to callback most 
hooks into stdlib...  But there's an easier way to do what you want.  Rather 
than do extensive gutting work on every layer of ogg/vorbis, why not just 
override the calls to malloc/calloc/realloc/free in stdlib completely using 
dlsym or LD_PRELOAD and be done with it?

Monty

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the Vorbis-dev mailing list