summaryrefslogtreecommitdiff
path: root/source4/libcli/raw
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-08-21 01:54:46 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:58:14 -0500
commitb83ba93eaeb2dcb0bf11615591d886fda84e4162 (patch)
treeb2fe3c5a6ea7a9bd1f5f416e545ee26d4a207ac5 /source4/libcli/raw
parent326f562e72c0776f469a8af93e25a2cc94dff60e (diff)
downloadsamba-b83ba93eaeb2dcb0bf11615591d886fda84e4162.tar.gz
samba-b83ba93eaeb2dcb0bf11615591d886fda84e4162.tar.bz2
samba-b83ba93eaeb2dcb0bf11615591d886fda84e4162.zip
r1983: a completely new implementation of talloc
This version does the following: 1) talloc_free(), talloc_realloc() and talloc_steal() lose their (redundent) first arguments 2) you can use _any_ talloc pointer as a talloc context to allocate more memory. This allows you to create complex data structures where the top level structure is the logical parent of the next level down, and those are the parents of the level below that. Then destroy either the lot with a single talloc_free() or destroy any sub-part with a talloc_free() of that part 3) you can name any pointer. Use talloc_named() which is just like talloc() but takes the printf style name argument as well as the parent context and the size. The whole thing ends up being a very simple piece of code, although some of the pointer walking gets hairy. So far, I'm just using the new talloc() like the old one. The next step is to actually take advantage of the new interface properly. Expect some new commits soon that simplify some common coding styles in samba4 by using the new talloc(). (This used to be commit e35bb094c52e550b3105dd1638d8d90de71d854f)
Diffstat (limited to 'source4/libcli/raw')
-rw-r--r--source4/libcli/raw/clisession.c2
-rw-r--r--source4/libcli/raw/clisocket.c2
-rw-r--r--source4/libcli/raw/clitransport.c8
-rw-r--r--source4/libcli/raw/clitree.c2
-rw-r--r--source4/libcli/raw/raweas.c2
-rw-r--r--source4/libcli/raw/rawfile.c6
-rw-r--r--source4/libcli/raw/rawfileinfo.c2
-rw-r--r--source4/libcli/raw/rawreadwrite.c4
-rw-r--r--source4/libcli/raw/rawrequest.c4
-rw-r--r--source4/libcli/raw/rawtrans.c4
10 files changed, 18 insertions, 18 deletions
diff --git a/source4/libcli/raw/clisession.c b/source4/libcli/raw/clisession.c
index f46c238378..0ee631a549 100644
--- a/source4/libcli/raw/clisession.c
+++ b/source4/libcli/raw/clisession.c
@@ -69,7 +69,7 @@ void smbcli_session_close(struct smbcli_session *session)
****************************************************************************/
struct smbcli_request *smb_raw_session_setup_send(struct smbcli_session *session, union smb_sesssetup *parms)
{
- struct smbcli_request *req;
+ struct smbcli_request *req = NULL;
switch (parms->generic.level) {
case RAW_SESSSETUP_GENERIC:
diff --git a/source4/libcli/raw/clisocket.c b/source4/libcli/raw/clisocket.c
index 343904999a..2bb50d200f 100644
--- a/source4/libcli/raw/clisocket.c
+++ b/source4/libcli/raw/clisocket.c
@@ -181,7 +181,7 @@ BOOL smbcli_sock_connect_byname(struct smbcli_socket *sock, const char *host, in
ret = smbcli_sock_connect(sock, &ip, port);
if (ret) {
- sock->hostname = talloc_steal(mem_ctx, sock->mem_ctx, name);
+ sock->hostname = talloc_steal(sock->mem_ctx, name);
}
talloc_destroy(mem_ctx);
diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c
index 91f0f0f8f5..82939467ae 100644
--- a/source4/libcli/raw/clitransport.c
+++ b/source4/libcli/raw/clitransport.c
@@ -296,7 +296,7 @@ static void smbcli_transport_finish_recv(struct smbcli_transport *transport)
{
uint8_t *buffer, *hdr, *vwv;
int len;
- uint16_t wct, mid = 0;
+ uint16_t wct=0, mid = 0;
struct smbcli_request *req;
buffer = transport->recv_buffer.buffer;
@@ -309,7 +309,7 @@ static void smbcli_transport_finish_recv(struct smbcli_transport *transport)
/* see if it could be an oplock break request */
if (handle_oplock_break(transport, len, hdr, vwv)) {
- talloc_free(transport->mem_ctx, buffer);
+ talloc_free(buffer);
return;
}
@@ -325,7 +325,7 @@ static void smbcli_transport_finish_recv(struct smbcli_transport *transport)
if (!req) goto error;
req->in.buffer = buffer;
- talloc_steal(transport->mem_ctx, req->mem_ctx, buffer);
+ talloc_steal(req->mem_ctx, 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(transport->mem_ctx, req->mem_ctx, buffer);
+ talloc_steal(req->mem_ctx, buffer);
req->in.size = len;
req->in.allocated = req->in.size;
diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c
index 97c0910451..57e322da32 100644
--- a/source4/libcli/raw/clitree.c
+++ b/source4/libcli/raw/clitree.c
@@ -70,7 +70,7 @@ void smbcli_tree_close(struct smbcli_tree *tree)
****************************************************************************/
struct smbcli_request *smb_tree_connect_send(struct smbcli_tree *tree, union smb_tcon *parms)
{
- struct smbcli_request *req;
+ struct smbcli_request *req = NULL;
switch (parms->tcon.level) {
case RAW_TCON_TCON:
diff --git a/source4/libcli/raw/raweas.c b/source4/libcli/raw/raweas.c
index e07fbcd288..d78f10fe1a 100644
--- a/source4/libcli/raw/raweas.c
+++ b/source4/libcli/raw/raweas.c
@@ -128,7 +128,7 @@ NTSTATUS ea_pull_list(const DATA_BLOB *blob,
blob2.data = blob->data + ofs;
blob2.length = ea_size - ofs;
- *eas = talloc_realloc(mem_ctx, *eas, sizeof(**eas) * (n+1));
+ *eas = talloc_realloc(*eas, sizeof(**eas) * (n+1));
if (! *eas) return NT_STATUS_NO_MEMORY;
len = ea_pull_struct(&blob2, mem_ctx, &(*eas)[n]);
diff --git a/source4/libcli/raw/rawfile.c b/source4/libcli/raw/rawfile.c
index 8bd8e5d8af..1b858d489a 100644
--- a/source4/libcli/raw/rawfile.c
+++ b/source4/libcli/raw/rawfile.c
@@ -34,7 +34,7 @@
struct smbcli_request *smb_raw_rename_send(struct smbcli_tree *tree,
union smb_rename *parms)
{
- struct smbcli_request *req;
+ struct smbcli_request *req = NULL;
switch (parms->generic.level) {
case RAW_RENAME_RENAME:
@@ -490,7 +490,7 @@ NTSTATUS smb_raw_open(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_o
****************************************************************************/
struct smbcli_request *smb_raw_close_send(struct smbcli_tree *tree, union smb_close *parms)
{
- struct smbcli_request *req;
+ struct smbcli_request *req = NULL;
switch (parms->generic.level) {
case RAW_CLOSE_GENERIC:
@@ -536,7 +536,7 @@ NTSTATUS smb_raw_close(struct smbcli_tree *tree, union smb_close *parms)
****************************************************************************/
struct smbcli_request *smb_raw_lock_send(struct smbcli_tree *tree, union smb_lock *parms)
{
- struct smbcli_request *req;
+ struct smbcli_request *req = NULL;
switch (parms->generic.level) {
case RAW_LOCK_GENERIC:
diff --git a/source4/libcli/raw/rawfileinfo.c b/source4/libcli/raw/rawfileinfo.c
index 9b82bf6fa0..aac8f2657b 100644
--- a/source4/libcli/raw/rawfileinfo.c
+++ b/source4/libcli/raw/rawfileinfo.c
@@ -174,7 +174,7 @@ static NTSTATUS smb_raw_info_backend(struct smbcli_session *session,
while (blob->length - ofs >= 24) {
uint_t n = parms->stream_info.out.num_streams;
parms->stream_info.out.streams =
- talloc_realloc(mem_ctx,parms->stream_info.out.streams,
+ talloc_realloc(parms->stream_info.out.streams,
(n+1) * sizeof(parms->stream_info.out.streams[0]));
if (!parms->stream_info.out.streams) {
return NT_STATUS_NO_MEMORY;
diff --git a/source4/libcli/raw/rawreadwrite.c b/source4/libcli/raw/rawreadwrite.c
index f0a9a063ed..dbca6fb7a5 100644
--- a/source4/libcli/raw/rawreadwrite.c
+++ b/source4/libcli/raw/rawreadwrite.c
@@ -33,7 +33,7 @@
struct smbcli_request *smb_raw_read_send(struct smbcli_tree *tree, union smb_read *parms)
{
BOOL bigoffset = False;
- struct smbcli_request *req;
+ struct smbcli_request *req = NULL;
switch (parms->generic.level) {
case RAW_READ_GENERIC:
@@ -185,7 +185,7 @@ NTSTATUS smb_raw_read(struct smbcli_tree *tree, union smb_read *parms)
struct smbcli_request *smb_raw_write_send(struct smbcli_tree *tree, union smb_write *parms)
{
BOOL bigoffset = False;
- struct smbcli_request *req;
+ struct smbcli_request *req = NULL;
switch (parms->generic.level) {
case RAW_WRITE_GENERIC:
diff --git a/source4/libcli/raw/rawrequest.c b/source4/libcli/raw/rawrequest.c
index bc87af4297..20a389af4c 100644
--- a/source4/libcli/raw/rawrequest.c
+++ b/source4/libcli/raw/rawrequest.c
@@ -224,7 +224,7 @@ static void smbcli_req_grow_allocation(struct smbcli_request *req, uint_t new_si
/* we need to realloc */
req->out.allocated = req->out.size + delta + REQ_OVER_ALLOCATION;
- buf2 = talloc_realloc(req->mem_ctx, req->out.buffer, req->out.allocated);
+ buf2 = talloc_realloc(req->out.buffer, req->out.allocated);
if (buf2 == NULL) {
smb_panic("out of memory in req_grow_allocation");
}
@@ -915,7 +915,7 @@ size_t smbcli_blob_append_string(struct smbcli_session *session,
max_len = (strlen(str)+2) * MAX_BYTES_PER_CHAR;
- blob->data = talloc_realloc(mem_ctx, blob->data, blob->length + max_len);
+ blob->data = talloc_realloc(blob->data, blob->length + max_len);
if (!blob->data) {
return 0;
}
diff --git a/source4/libcli/raw/rawtrans.c b/source4/libcli/raw/rawtrans.c
index 53f8075822..49b43dd930 100644
--- a/source4/libcli/raw/rawtrans.c
+++ b/source4/libcli/raw/rawtrans.c
@@ -84,7 +84,7 @@ NTSTATUS smb_raw_trans2_recv(struct smbcli_request *req,
/* allocate it */
if (total_data != 0) {
- tdata = talloc_realloc(mem_ctx, parms->out.data.data,total_data);
+ tdata = talloc_realloc(parms->out.data.data,total_data);
if (!tdata) {
DEBUG(0,("smb_raw_receive_trans: failed to enlarge data buffer to %d bytes\n", total_data));
req->status = NT_STATUS_NO_MEMORY;
@@ -94,7 +94,7 @@ NTSTATUS smb_raw_trans2_recv(struct smbcli_request *req,
}
if (total_param != 0) {
- tparam = talloc_realloc(mem_ctx, parms->out.params.data,total_param);
+ tparam = talloc_realloc(parms->out.params.data,total_param);
if (!tparam) {
DEBUG(0,("smb_raw_receive_trans: failed to enlarge param buffer to %d bytes\n", total_param));
req->status = NT_STATUS_NO_MEMORY;