summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-01-07 17:48:10 +0100
committerVolker Lendecke <vl@samba.org>2009-01-08 22:29:53 +0100
commit52b6756c4e5c0ab7cd74e23de36ac5df217d103b (patch)
tree7b5debf97c1cb33328286064f7bae04b2e0514ef
parent5a4f71d40cbcfc67802fb2cbc45d8d74a9312342 (diff)
downloadsamba-52b6756c4e5c0ab7cd74e23de36ac5df217d103b.tar.gz
samba-52b6756c4e5c0ab7cd74e23de36ac5df217d103b.tar.bz2
samba-52b6756c4e5c0ab7cd74e23de36ac5df217d103b.zip
Make samr_info a talloc context of its own
-rw-r--r--source3/rpc_server/srv_samr_nt.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c
index afaf564419..8ab4715a51 100644
--- a/source3/rpc_server/srv_samr_nt.c
+++ b/source3/rpc_server/srv_samr_nt.c
@@ -73,7 +73,6 @@ struct samr_info {
uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */
uint32 acc_granted;
DISP_INFO *disp_info;
- TALLOC_CTX *mem_ctx;
};
static const struct generic_mapping sam_generic_mapping = {
@@ -357,11 +356,12 @@ static DISP_INFO *get_samr_dispinfo_by_sid(DOM_SID *psid)
Create a samr_info struct.
********************************************************************/
+static int samr_info_destructor(struct samr_info *info);
+
static struct samr_info *get_samr_info_by_sid(DOM_SID *psid)
{
struct samr_info *info;
fstring sid_str;
- TALLOC_CTX *mem_ctx;
if (psid) {
sid_to_fstring(sid_str, psid);
@@ -369,10 +369,10 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid)
fstrcpy(sid_str,"(NULL)");
}
- mem_ctx = talloc_init("samr_info for domain sid %s", sid_str);
-
- if ((info = TALLOC_ZERO_P(mem_ctx, struct samr_info)) == NULL)
+ if ((info = TALLOC_ZERO_P(NULL, struct samr_info)) == NULL) {
return NULL;
+ }
+ talloc_set_destructor(info, samr_info_destructor);
DEBUG(10,("get_samr_info_by_sid: created new info for sid %s\n", sid_str));
if (psid) {
@@ -382,7 +382,6 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid)
DEBUG(10,("get_samr_info_by_sid: created new info for NULL sid.\n"));
info->builtin_domain = False;
}
- info->mem_ctx = mem_ctx;
info->disp_info = get_samr_dispinfo_by_sid(psid);
@@ -433,22 +432,24 @@ static void free_samr_cache(DISP_INFO *disp_info)
unbecome_root();
}
-/*******************************************************************
- Function to free the per handle data.
- ********************************************************************/
-
-static void free_samr_info(void *ptr)
+static int samr_info_destructor(struct samr_info *info)
{
- struct samr_info *info=(struct samr_info *) ptr;
-
/* Only free the dispinfo cache if no one bothered to set up
a timeout. */
if (info->disp_info && info->disp_info->cache_timeout_event == NULL) {
free_samr_cache(info->disp_info);
}
+ return 0;
+}
+
+/*******************************************************************
+ Function to free the per handle data.
+ ********************************************************************/
- talloc_destroy(info->mem_ctx);
+static void free_samr_info(void *ptr)
+{
+ TALLOC_FREE(ptr);
}
/*******************************************************************