diff options
author | Andrew Tridgell <tridge@samba.org> | 2006-10-21 00:10:19 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:15:35 -0500 |
commit | 7a390a0dabcdadb30196662b6cdec512bf81dcb4 (patch) | |
tree | 8ed126e072e4446ad47d25f277059af5ccd556cc /source3/lib/ldb/common/ldb_attributes.c | |
parent | aa3ca346d82da2501406cc1f482643b20905e467 (diff) | |
download | samba-7a390a0dabcdadb30196662b6cdec512bf81dcb4.tar.gz samba-7a390a0dabcdadb30196662b6cdec512bf81dcb4.tar.bz2 samba-7a390a0dabcdadb30196662b6cdec512bf81dcb4.zip |
r19430: merge recent ldb changes from Samba4. This includes memory leak fixes
and significant speedups
(This used to be commit bb5c205fef90aa8b89ba400fb9f2f37a111676a8)
Diffstat (limited to 'source3/lib/ldb/common/ldb_attributes.c')
-rw-r--r-- | source3/lib/ldb/common/ldb_attributes.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/source3/lib/ldb/common/ldb_attributes.c b/source3/lib/ldb/common/ldb_attributes.c index c8a7909b4c..2d9f0e6cf8 100644 --- a/source3/lib/ldb/common/ldb_attributes.c +++ b/source3/lib/ldb/common/ldb_attributes.c @@ -39,6 +39,7 @@ int ldb_set_attrib_handlers(struct ldb_context *ldb, const struct ldb_attrib_handler *handlers, unsigned num_handlers) { + int i; struct ldb_attrib_handler *h; h = talloc_realloc(ldb, ldb->schema.attrib_handlers, struct ldb_attrib_handler, @@ -50,6 +51,16 @@ int ldb_set_attrib_handlers(struct ldb_context *ldb, ldb->schema.attrib_handlers = h; memcpy(h + ldb->schema.num_attrib_handlers, handlers, sizeof(*h) * num_handlers); + for (i=0;i<num_handlers;i++) { + if (h[ldb->schema.num_attrib_handlers+i].flags & LDB_ATTR_FLAG_ALLOCATED) { + h[ldb->schema.num_attrib_handlers+i].attr = talloc_strdup(ldb->schema.attrib_handlers, + h[ldb->schema.num_attrib_handlers+i].attr); + if (h[ldb->schema.num_attrib_handlers+i].attr == NULL) { + ldb_oom(ldb); + return -1; + } + } + } ldb->schema.num_attrib_handlers += num_handlers; return 0; } @@ -129,6 +140,9 @@ void ldb_remove_attrib_handler(struct ldb_context *ldb, const char *attrib) if (h == &ldb_default_attrib_handler) { return; } + if (h->flags & LDB_ATTR_FLAG_ALLOCATED) { + talloc_free(h->attr); + } i = h - ldb->schema.attrib_handlers; if (i < ldb->schema.num_attrib_handlers - 1) { memmove(&ldb->schema.attrib_handlers[i], |