summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-07-27 00:47:19 +0000
committerJeremy Allison <jra@samba.org>2000-07-27 00:47:19 +0000
commit5ec1642809d9de83da8c88c65d6595c6eb0270f5 (patch)
treef6f4f1e0b3678394fca8b7c37f71084a1b166671 /source3/lib
parent134a4b86548db77cba292c50fbd6b91ecaa69f14 (diff)
downloadsamba-5ec1642809d9de83da8c88c65d6595c6eb0270f5.tar.gz
samba-5ec1642809d9de83da8c88c65d6595c6eb0270f5.tar.bz2
samba-5ec1642809d9de83da8c88c65d6595c6eb0270f5.zip
Ok - this is a *BIG* change - but it fixes the problems with static strings
in the RPC code. This change was prompted by trying to save a long (>256) character comment in the printer properties page. The new system associates a TALLOC_CTX with the pipe struct, and frees the pool on return of a complete PDU. A global TALLOC_CTX is used for the odd buffer allocated in the BUFFERxx code, and is freed in the main loop. This code works with insure, and seems to be free of memory leaks and crashes (so far) but there are probably the occasional problem with code that uses UNISTRxx structs on the stack and expects them to contain storage without doing a init_unistrXX(). This means that rpcclient will probably be horribly broken. A TALLOC_CTX also needed associating with the struct cli_state also, to make the prs_xx code there work. The main interface change is the addition of a TALLOC_CTX to the prs_init calls - used for dynamic allocation in the prs_XXX calls. Now this is in place it should make dynamic allocation of all RPC memory on unmarshall *much* easier to fix. Jeremy. (This used to be commit 0ff2ce543ee54f7364e6d839db6d06e7ef1edcf4)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/cmd_interp.c1
-rw-r--r--source3/lib/msrpc-client.c2
-rw-r--r--source3/lib/talloc.c9
3 files changed, 10 insertions, 2 deletions
diff --git a/source3/lib/cmd_interp.c b/source3/lib/cmd_interp.c
index a9a1ad0e6b..a029d0bbd2 100644
--- a/source3/lib/cmd_interp.c
+++ b/source3/lib/cmd_interp.c
@@ -349,6 +349,7 @@ static uint32 do_command(struct client_info *info, char *line)
}
free_char_array(cmd_argc, cmd_argv);
+ parse_talloc_free(); /* Free up init_XXX memory. */
return status;
}
diff --git a/source3/lib/msrpc-client.c b/source3/lib/msrpc-client.c
index 60924ed81c..ee3ee0adcc 100644
--- a/source3/lib/msrpc-client.c
+++ b/source3/lib/msrpc-client.c
@@ -36,7 +36,7 @@ BOOL receive_msrpc(int fd, prs_struct *data, unsigned int timeout)
size_t len;
RPC_HDR hdr;
- prs_init(data, 0, 4, True);
+ prs_init(data, 0, 4, NULL, True);
ok = prs_read(data, fd, 16, timeout);
diff --git a/source3/lib/talloc.c b/source3/lib/talloc.c
index 35d4ddd211..31594d2a01 100644
--- a/source3/lib/talloc.c
+++ b/source3/lib/talloc.c
@@ -81,7 +81,7 @@ void *talloc(TALLOC_CTX *t, size_t size)
}
/* destroy a whole pool */
-void talloc_destroy(TALLOC_CTX *t)
+void talloc_destroy_pool(TALLOC_CTX *t)
{
struct talloc_chunk *c;
@@ -92,5 +92,12 @@ void talloc_destroy(TALLOC_CTX *t)
t->list = c;
}
+ t->list = NULL;
+}
+
+/* destroy a whole pool including the context */
+void talloc_destroy(TALLOC_CTX *t)
+{
+ talloc_destroy_pool(t);
free(t);
}