svn commit: samba r7759 - in branches/SAMBA_4_0/source/lib/ldb/common: .

derrell at samba.org derrell at samba.org
Wed Jun 22 00:06:49 GMT 2005


Andrew Tridgell <tridge at osdl.org> writes:

> Derrell,
>
>  > Shouldn't this be talloc_strdup("ldb not connected")?  The error string from
>  > some modules is likely to have to be allocated, as it may be coming,
>  > initially, from an external library which malloc()s it, so the string will
>  > have to be talloc_strdup()ed to be returned. (e.g. sqlite).
>
> No. The caller does not free in this API. It's fine for a backend to
> allocate the string, in which case the backend will need to do
> something like this:
>
>   talloc_free(mybackend->last_error_string);
>   mybackend->last_error_string = talloc_strdup(mybackend, "a new error");
>   return mybackend->last_error_string;

That's kinda yucky.  (No, that's really yucky.)  Is there some reason that you
wouldn't want the caller to just free the error string, or better yet, for the
error string to always just be allocated on the ldb context so that it gets
freed automagically?  With everything so clean in ldb, this seems like a real
oversight.

Derrell


More information about the samba-technical mailing list