summaryrefslogtreecommitdiff
path: root/source4/lib/ldb
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/ldb')
-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;