summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-09-22 22:14:30 -0700
committerMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>2009-10-02 12:45:04 +0200
commite7846f69cacdd0551fcd777a71bf833a2fc9ca2b (patch)
tree184472e9ef83425418cf4db553d477f6c43094df
parent14c9070322d089dd96b389e8087c4f4bf1a6c7cc (diff)
downloadsamba-e7846f69cacdd0551fcd777a71bf833a2fc9ca2b.tar.gz
samba-e7846f69cacdd0551fcd777a71bf833a2fc9ca2b.tar.bz2
samba-e7846f69cacdd0551fcd777a71bf833a2fc9ca2b.zip
s4-ldb: overallocate idxptr to reduce memory fragmentation
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_index.c4
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;