diff options
author | Andrew Tridgell <tridge@samba.org> | 2009-09-22 22:14:30 -0700 |
---|---|---|
committer | Matthias Dieter Wallnöfer <mwallnoefer@yahoo.de> | 2009-10-02 12:45:04 +0200 |
commit | e7846f69cacdd0551fcd777a71bf833a2fc9ca2b (patch) | |
tree | 184472e9ef83425418cf4db553d477f6c43094df /source4/lib/ldb | |
parent | 14c9070322d089dd96b389e8087c4f4bf1a6c7cc (diff) | |
download | samba-e7846f69cacdd0551fcd777a71bf833a2fc9ca2b.tar.gz samba-e7846f69cacdd0551fcd777a71bf833a2fc9ca2b.tar.bz2 samba-e7846f69cacdd0551fcd777a71bf833a2fc9ca2b.zip |
s4-ldb: overallocate idxptr to reduce memory fragmentation
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r-- | source4/lib/ldb/ldb_tdb/ldb_index.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c index 0b96e07a7d..1acbc204f7 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_index.c +++ b/source4/lib/ldb/ldb_tdb/ldb_index.c @@ -70,8 +70,10 @@ static int ltdb_idxptr_add(struct ldb_module *module, const struct ldb_message * { void *data = ldb_module_get_private(module); struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); + /* we overallocate a bit to save on memory fragmentation */ + unsigned alloc_length = ((ltdb->idxptr->num_dns+1) + 16) & ~15; ltdb->idxptr->dn_list = talloc_realloc(ltdb->idxptr, ltdb->idxptr->dn_list, - struct TDB_DATA, ltdb->idxptr->num_dns+1); + struct TDB_DATA, alloc_length); if (ltdb->idxptr->dn_list == NULL) { ltdb->idxptr->num_dns = 0; return LDB_ERR_OPERATIONS_ERROR; |