From 159f81ee32dbd7c832fb8c3723d0f0207d039078 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 25 Sep 2004 13:28:38 +0000 Subject: r2635: mem_ctx cleanups on the lsa and netlogon pipes in the rpc server (This used to be commit 1ee5ed4197f49f12372835f66160801f19ee35a6) --- source4/rpc_server/lsa/dcesrv_lsa.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'source4/rpc_server/lsa') diff --git a/source4/rpc_server/lsa/dcesrv_lsa.c b/source4/rpc_server/lsa/dcesrv_lsa.c index f07997f3d6..f5bcae719b 100644 --- a/source4/rpc_server/lsa/dcesrv_lsa.c +++ b/source4/rpc_server/lsa/dcesrv_lsa.c @@ -38,7 +38,6 @@ enum lsa_handle { struct lsa_policy_state { int reference_count; void *sam_ctx; - TALLOC_CTX *mem_ctx; uint32_t access_mask; const char *domain_dn; }; @@ -51,7 +50,7 @@ static void lsa_Policy_close(struct lsa_policy_state *state) { state->reference_count--; if (state->reference_count == 0) { - talloc_destroy(state->mem_ctx); + talloc_free(state); } } @@ -145,40 +144,33 @@ static NTSTATUS lsa_OpenPolicy2(struct dcesrv_call_state *dce_call, TALLOC_CTX * { struct lsa_policy_state *state; struct dcesrv_handle *handle; - TALLOC_CTX *lsa_mem_ctx; ZERO_STRUCTP(r->out.handle); - lsa_mem_ctx = talloc_init("lsa_OpenPolicy"); - if (!lsa_mem_ctx) { - return NT_STATUS_NO_MEMORY; - } - - state = talloc_p(lsa_mem_ctx, struct lsa_policy_state); + state = talloc_p(dce_call->conn, struct lsa_policy_state); if (!state) { return NT_STATUS_NO_MEMORY; } - state->mem_ctx = lsa_mem_ctx; /* make sure the sam database is accessible */ - state->sam_ctx = samdb_connect(state->mem_ctx); + state->sam_ctx = samdb_connect(state); if (state->sam_ctx == NULL) { - talloc_destroy(state->mem_ctx); + talloc_free(state); return NT_STATUS_INVALID_SYSTEM_SERVICE; } /* work out the domain_dn - useful for so many calls its worth fetching here */ - state->domain_dn = samdb_search_string(state->sam_ctx, state->mem_ctx, NULL, + state->domain_dn = samdb_search_string(state->sam_ctx, state, NULL, "dn", "(&(objectClass=domain)(!(objectclass=builtinDomain)))"); if (!state->domain_dn) { - talloc_destroy(state->mem_ctx); + talloc_free(state); return NT_STATUS_NO_SUCH_DOMAIN; } handle = dcesrv_handle_new(dce_call->conn, LSA_HANDLE_POLICY); if (!handle) { - talloc_destroy(state->mem_ctx); + talloc_free(state); return NT_STATUS_NO_MEMORY; } -- cgit