[PATCH] ctdb: Use provided mem_ctx for newly allocated memory

Swen Schillig swen at vnet.ibm.com
Fri Mar 9 08:03:46 UTC 2018


Please review and push if ok.

Thanks in advance.

Cheers Swen
-------------- next part --------------
From 88d314476d677ca3d32f82ebcf1e780c0c5bb483 Mon Sep 17 00:00:00 2001
From: Swen Schillig <swen at vnet.ibm.com>
Date: Wed, 21 Feb 2018 13:34:28 +0100
Subject: [PATCH] ctdb: Use provided mem_ctx for newly allocated memory

ctdb_call_local is called with a mem_ctx parameter which should be used
for newly allocated memory.

This is safe because all allocations of this context are freed before
this function returns.

In addition this offers the opportunity to provide a pooled context,
optimizing the memory handling.

Signed-off-by: Swen Schillig <swen at vnet.ibm.com>
---
 ctdb/client/ctdb_client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c
index d399cb551f6..c3bb435a641 100644
--- a/ctdb/client/ctdb_client.c
+++ b/ctdb/client/ctdb_client.c
@@ -86,7 +86,7 @@ int ctdb_call_local(struct ctdb_db_context *ctdb_db, struct ctdb_call *call,
 	struct ctdb_registered_call *fn;
 	struct ctdb_context *ctdb = ctdb_db->ctdb;
 	
-	c = talloc(ctdb, struct ctdb_call_info);
+	c = talloc(mem_ctx, struct ctdb_call_info);
 	CTDB_NO_MEMORY(ctdb, c);
 
 	c->key = call->key;
-- 
2.14.3



More information about the samba-technical mailing list