[Libburn] some questions

Steven Van Impe steven.vanimpe at telenet.be
Fri Nov 19 06:40:56 PST 2004

> > > > 1) Why the pointer pointers for 'me' ? Why are these better than (or
> > > > needed instead of) just regular pointers to a struct iso_tree_file or
> > > > struct iso_tree_dir ?
> > > 
> > > Yeah, I'd like that explained too.
> > > 
> > > At a _really_ brief glance, I can't tell why the "me" field is required in 
> > > those structs at all.

I think I figured this one out:
The add_dir and add_file functions return some sort of reference to the
directory or file added, but you can't just pass a regular pointer,
since the addresses of the directories and files can change (after
realloc, or after qsort).
Using the me-pointer is safe since it points to a malloced pointer that
will not get reallocated or moved (though you have to update it's
content to keep it sane).

> > I always thought literals were only kept for the scope of the expression
> > they're used in (since most of the time, you either _copy_ their value
> > into a variable or use them to calculate some value that is then
> > _copied_ into a variable).
> Nope.  They're stored in the object file and accessible any time.

Aha :)

> > Though I don't think this construction is sane (the memory held by "foo"
> > will probably be freed after the assignment and might be overwritten).
> > When declaring stuff as a pointer, shouldn't we use malloc/free ?
> It's perfectly sane.  (Just make sure you don't try to modify the "foo"
> string: string literals are often read-only and modifying them invokes
> undefined behavior.)

I see, but isn't it safer to avoid using a construction like this (and
instead point ext to the NULL at the end of name, like Derek said) ?

More information about the libburn mailing list