TALLOC_CTX to ldb_search()?
simo
idra at samba.org
Mon Dec 4 06:38:16 GMT 2006
On Mon, 2006-12-04 at 17:24 +1100, tridge at samba.org wrote:
> Volker,
>
> > To me this looks a bit unnatural and error-prone. Having an
> > explicit mem_ctx makes it easier to hook it to a
> > procedure-local temporary ctx and have it automatically
> > freed.
>
> If we'd been designing it now, I would have chosen to have a mem_ctx
> argument. The question really is whether it's worth changing it now.
>
> One option is to leave the current function, and add a new one which
> also gives us a printf style argument for the expression. The most
> common pattern of usage seems to be like this:
>
> expr = talloc_asprintf(ldb, "(&(gidNumber=%u)(objectClass=groupMap))",
> (unsigned)gid);
> if (expr == NULL) goto failed;
> ret = ldb_search(ldb, NULL, LDB_SCOPE_SUBTREE, expr, NULL, &res);
> talloc_steal(expr, res);
>
> if we had a varargs printf style argument to a function like
> ldb_search which also put the result on a specified talloc context
> then this would become one function, and I think that would be the
> most friendly for programmers.
>
> But what to call the function?? :-)
I can add an ldb_search_fmt() function.
Prototype:
int ldb_search_exp_fmt( TALLOC_CTX *memctx, struct ldb_context *ldb, struct ldb_result **result
struct ldb_dn *base, enum ldb_scope scope, const char * const *attrs,
const char *exp_fmt, ...);
Let me know if you think this would be ok.
Simo.
--
Simo Sorce
Samba Team GPL Compliance Officer
email: idra at samba.org
http://samba.org
More information about the samba-technical
mailing list