summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-08-21 02:07:12 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:58:14 -0500
commitb45f4ebbb880e41abf86abb54264123f3edbde05 (patch)
tree09d1d3d453f5976577904ca4ec2cf46d8a5de47c /source4
parentb83ba93eaeb2dcb0bf11615591d886fda84e4162 (diff)
downloadsamba-b45f4ebbb880e41abf86abb54264123f3edbde05.tar.gz
samba-b45f4ebbb880e41abf86abb54264123f3edbde05.tar.bz2
samba-b45f4ebbb880e41abf86abb54264123f3edbde05.zip
r1984: this change is what you should read to understand the new talloc()
It simplifies our structure handling a lot, making the code shorter and easier to understand. Look at the diff carefully and see if you can understand it. If you're still confused then please ask. (This used to be commit 03c341aca7f09cb1f0d33ec65e074e6a00caa30f)
Diffstat (limited to 'source4')
-rw-r--r--source4/include/cli_context.h3
-rw-r--r--source4/libcli/raw/clitransport.c4
-rw-r--r--source4/libcli/raw/rawrequest.c17
3 files changed, 5 insertions, 19 deletions
diff --git a/source4/include/cli_context.h b/source4/include/cli_context.h
index f289d5b546..9013d3d071 100644
--- a/source4/include/cli_context.h
+++ b/source4/include/cli_context.h
@@ -244,9 +244,6 @@ struct smbcli_request {
/* allow a request to be part of a list of requests */
struct smbcli_request *next, *prev;
- /* a talloc context for the lifetime of this request */
- TALLOC_CTX *mem_ctx;
-
/* each request is in one of 4 possible states */
enum smbcli_request_state state;
diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c
index 82939467ae..5766fde03a 100644
--- a/source4/libcli/raw/clitransport.c
+++ b/source4/libcli/raw/clitransport.c
@@ -325,7 +325,7 @@ static void smbcli_transport_finish_recv(struct smbcli_transport *transport)
if (!req) goto error;
req->in.buffer = buffer;
- talloc_steal(req->mem_ctx, buffer);
+ talloc_steal(req, buffer);
req->in.size = len;
req->in.allocated = req->in.size;
goto async;
@@ -349,7 +349,7 @@ static void smbcli_transport_finish_recv(struct smbcli_transport *transport)
/* fill in the 'in' portion of the matching request */
req->in.buffer = buffer;
- talloc_steal(req->mem_ctx, buffer);
+ talloc_steal(req, buffer);
req->in.size = len;
req->in.allocated = req->in.size;
diff --git a/source4/libcli/raw/rawrequest.c b/source4/libcli/raw/rawrequest.c
index 20a389af4c..87bbe5a31b 100644
--- a/source4/libcli/raw/rawrequest.c
+++ b/source4/libcli/raw/rawrequest.c
@@ -49,7 +49,7 @@ NTSTATUS smbcli_request_destroy(struct smbcli_request *req)
/* ahh, its so nice to destroy a complex structure in such a
simple way! */
status = req->status;
- talloc_destroy(req->mem_ctx);
+ talloc_free(req);
return status;
}
@@ -61,18 +61,8 @@ NTSTATUS smbcli_request_destroy(struct smbcli_request *req)
struct smbcli_request *smbcli_request_setup_nonsmb(struct smbcli_transport *transport, uint_t size)
{
struct smbcli_request *req;
- TALLOC_CTX *mem_ctx;
-
- /* each request gets its own talloc context. The request
- structure itself is also allocated inside this context,
- so we need to allocate it before we construct the request
- */
- mem_ctx = talloc_init("smbcli_request");
- if (!mem_ctx) {
- return NULL;
- }
- req = talloc(mem_ctx, sizeof(struct smbcli_request));
+ req = talloc_named(NULL, sizeof(struct smbcli_request), "smcli_request");
if (!req) {
return NULL;
}
@@ -80,7 +70,6 @@ struct smbcli_request *smbcli_request_setup_nonsmb(struct smbcli_transport *tran
/* setup the request context */
req->state = SMBCLI_REQUEST_INIT;
- req->mem_ctx = mem_ctx;
req->transport = transport;
req->session = NULL;
req->tree = NULL;
@@ -89,7 +78,7 @@ struct smbcli_request *smbcli_request_setup_nonsmb(struct smbcli_transport *tran
/* over allocate by a small amount */
req->out.allocated = req->out.size + REQ_OVER_ALLOCATION;
- req->out.buffer = talloc(req->mem_ctx, req->out.allocated);
+ req->out.buffer = talloc(req, req->out.allocated);
if (!req->out.buffer) {
return NULL;
}