>
> > > > The caller should probably own the data returned here (other backends
> > > > use strdup for valid values, and NULL be used on error paths).
> >
> > If the value is a "const" pointer, the caller doesn't own it, because
> > you can't "free" a const pointer.
> >
> > But it's right, the semantics of ownership must be well-defined.
>
> My thought was to just make *all* password functions return new memory
> for the caller to manage rather than trying to make special cases.
>

I don't like the idea of allocating memory to copy string constants or
callee-owned data just to provide consistent semantics. I prefer tracking
any memory that needs to be freed, ie my suggestion to add a bool field to
SmbAuthData. Not my call, though.

> Because these functions return pointers into a larger object (the
> > global configuration).  They are just looking up existing objects.
>
> If they all strdup(), the caller has obvious semantics, no? The extra
> memory won't float around too long I would expect (and there are usually
> pitfalls where "this is owned by someone else" pointers are used
> anyways).
>

They don't call strdup(), GetBlockValue IIRC eventually calls c_str() on
members of larger data structures.
_______________________________________________
mpd-devel mailing list
[email protected]
http://mailman.blarg.de/listinfo/mpd-devel

Reply via email to