From d938c0b591d9c4aff9c92ae5eedd26ed97455f42 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 19 Jun 2012 12:42:08 +0930 Subject: ntdb: allocator attribute. This is designed to allow us to make ntdb_context (and NTDB_DATA returned from ntdb_fetch) a talloc pointer. But it can also be used for any other alternate allocator. Signed-off-by: Rusty Russell --- lib/ntdb/lock.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'lib/ntdb/lock.c') diff --git a/lib/ntdb/lock.c b/lib/ntdb/lock.c index 625a2c4934..95824db742 100644 --- a/lib/ntdb/lock.c +++ b/lib/ntdb/lock.c @@ -387,10 +387,16 @@ static enum NTDB_ERROR ntdb_nest_lock(struct ntdb_context *ntdb, "ntdb_nest_lock: already have a hash lock?"); } #endif - - new_lck = (struct ntdb_lock *)realloc( - ntdb->file->lockrecs, - sizeof(*ntdb->file->lockrecs) * (ntdb->file->num_lockrecs+1)); + if (ntdb->file->lockrecs == NULL) { + new_lck = ntdb->alloc_fn(ntdb->file, sizeof(*ntdb->file->lockrecs), + ntdb->alloc_data); + } else { + new_lck = (struct ntdb_lock *)ntdb->expand_fn( + ntdb->file->lockrecs, + sizeof(*ntdb->file->lockrecs) + * (ntdb->file->num_lockrecs+1), + ntdb->alloc_data); + } if (new_lck == NULL) { return ntdb_logerr(ntdb, NTDB_ERR_OOM, NTDB_LOG_ERROR, "ntdb_nest_lock:" -- cgit