summaryrefslogtreecommitdiff
path: root/lib/ntdb/lock.c
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2012-06-19 12:42:08 +0930
committerRusty Russell <rusty@rustcorp.com.au>2012-06-19 05:38:07 +0200
commitd938c0b591d9c4aff9c92ae5eedd26ed97455f42 (patch)
treee3744f9c660fbf23d759493e0391d577e528ffcd /lib/ntdb/lock.c
parent6d5a3e1602a1db8ca8e778f5e4f40bb623dff1e7 (diff)
downloadsamba-d938c0b591d9c4aff9c92ae5eedd26ed97455f42.tar.gz
samba-d938c0b591d9c4aff9c92ae5eedd26ed97455f42.tar.bz2
samba-d938c0b591d9c4aff9c92ae5eedd26ed97455f42.zip
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 <rusty@rustcorp.com.au>
Diffstat (limited to 'lib/ntdb/lock.c')
-rw-r--r--lib/ntdb/lock.c14
1 files changed, 10 insertions, 4 deletions
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:"