diff options
author | Andrew Bartlett <abartlet@samba.org> | 2010-03-16 14:41:51 +1100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2010-03-16 19:25:14 +1100 |
commit | 1e6fee4185b726e532c98e0feec1121d59f734c5 (patch) | |
tree | c7669da40c5b088ea143aab8399674dc6f0142ce /source4/dsdb/schema | |
parent | c874b9f42eebacd9ad6baa90309635db8b8ec3fb (diff) | |
download | samba-1e6fee4185b726e532c98e0feec1121d59f734c5.tar.gz samba-1e6fee4185b726e532c98e0feec1121d59f734c5.tar.bz2 samba-1e6fee4185b726e532c98e0feec1121d59f734c5.zip |
s4:dsdb Add a memory context for dsdb_get_schema()
When specified, we talloc_reference onto this context to ensure that
pointers found in it are valid for the life of the objects they are
placed into. (Such as the string form of LDAP attributes).
Andrew Bartlett
Diffstat (limited to 'source4/dsdb/schema')
-rw-r--r-- | source4/dsdb/schema/schema_set.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c index 305a0d94f3..e8fe7c4c65 100644 --- a/source4/dsdb/schema/schema_set.c +++ b/source4/dsdb/schema/schema_set.c @@ -413,9 +413,11 @@ int dsdb_set_global_schema(struct ldb_context *ldb) /** * Find the schema object for this ldb + * + * If reference_ctx is not NULL, then talloc_reference onto that context */ -struct dsdb_schema *dsdb_get_schema(struct ldb_context *ldb) +struct dsdb_schema *dsdb_get_schema(struct ldb_context *ldb, TALLOC_CTX *reference_ctx) { const void *p; struct dsdb_schema *schema; @@ -431,7 +433,11 @@ struct dsdb_schema *dsdb_get_schema(struct ldb_context *ldb) return NULL; } - return schema; + if (!reference_ctx) { + return schema; + } else { + return talloc_reference(reference_ctx, schema); + } } /** @@ -440,7 +446,7 @@ struct dsdb_schema *dsdb_get_schema(struct ldb_context *ldb) void dsdb_make_schema_global(struct ldb_context *ldb) { - struct dsdb_schema *schema = dsdb_get_schema(ldb); + struct dsdb_schema *schema = dsdb_get_schema(ldb, NULL); if (!schema) { return; } |