struct make "struct shadow_copy_data" its own talloc context
authorVolker Lendecke <vl@samba.org>
Mon, 30 May 2011 10:11:53 +0000 (12:11 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 31 May 2011 19:47:07 +0000 (21:47 +0200)
source3/include/ntioctl.h
source3/modules/vfs_shadow_copy.c
source3/modules/vfs_shadow_copy2.c
source3/smbd/nttrans.c

index 3ed4a194a731c4d540e0e888438a90cce15a5498..18707c5bbe2780972974f6a5d0e19ff2fdb58f94 100644 (file)
@@ -78,7 +78,6 @@
 typedef char SHADOW_COPY_LABEL[25];
 
 struct shadow_copy_data {
-       TALLOC_CTX *mem_ctx;
        /* Total number of shadow volumes currently mounted */
        uint32 num_volumes;
        /* Concatenated list of labels */
index c1ffac749897c4b330dc1c15f59c1f292ea690dd..1db47d216be3f362ae630d5f7eaf12a63718a8e0 100644 (file)
@@ -253,7 +253,7 @@ static int shadow_copy_get_shadow_copy_data(vfs_handle_struct *handle,
                        continue;
                }
 
-               tlabels = (SHADOW_COPY_LABEL *)TALLOC_REALLOC(shadow_copy_data->mem_ctx,
+               tlabels = (SHADOW_COPY_LABEL *)TALLOC_REALLOC(shadow_copy_data,
                                                                        shadow_copy_data->labels,
                                                                        (shadow_copy_data->num_volumes+1)*sizeof(SHADOW_COPY_LABEL));
                if (tlabels == NULL) {
index fd32f174e803de209eba1df4ef1b96b5596049c1..25cc5d4a028d92231efa0d201531b75d40591558 100644 (file)
@@ -918,7 +918,7 @@ static int shadow_copy2_get_shadow_copy2_data(vfs_handle_struct *handle,
                        continue;
                }
 
-               tlabels = talloc_realloc(shadow_copy2_data->mem_ctx,
+               tlabels = talloc_realloc(shadow_copy2_data,
                                         shadow_copy2_data->labels,
                                         SHADOW_COPY_LABEL, shadow_copy2_data->num_volumes+1);
                if (tlabels == NULL) {
index 1d0c9614a9bedfbfc290defe19d61c06dcbb8356..18d5979e3c2755fdf0b7e5e8f312e512dc23fc56 100644 (file)
@@ -2215,7 +2215,6 @@ static void call_nt_transact_ioctl(connection_struct *conn,
                 * it be deallocated when we return.
                 */
                struct shadow_copy_data *shadow_data = NULL;
-               TALLOC_CTX *shadow_mem_ctx = NULL;
                bool labels = False;
                uint32 labels_data_count = 0;
                uint32 i;
@@ -2236,29 +2235,19 @@ static void call_nt_transact_ioctl(connection_struct *conn,
                        labels = True;
                }
 
-               shadow_mem_ctx = talloc_init("SHADOW_COPY_DATA");
-               if (shadow_mem_ctx == NULL) {
-                       DEBUG(0,("talloc_init(SHADOW_COPY_DATA) failed!\n"));
-                       reply_nterror(req, NT_STATUS_NO_MEMORY);
-                       return;
-               }
-
-               shadow_data = TALLOC_ZERO_P(shadow_mem_ctx,
+               shadow_data = TALLOC_ZERO_P(talloc_tos(),
                                            struct shadow_copy_data);
                if (shadow_data == NULL) {
                        DEBUG(0,("TALLOC_ZERO() failed!\n"));
-                       talloc_destroy(shadow_mem_ctx);
                        reply_nterror(req, NT_STATUS_NO_MEMORY);
                        return;
                }
 
-               shadow_data->mem_ctx = shadow_mem_ctx;
-
                /*
                 * Call the VFS routine to actually do the work.
                 */
                if (SMB_VFS_GET_SHADOW_COPY_DATA(fsp, shadow_data, labels)!=0) {
-                       talloc_destroy(shadow_data->mem_ctx);
+                       TALLOC_FREE(shadow_data);
                        if (errno == ENOSYS) {
                                DEBUG(5,("FSCTL_GET_SHADOW_COPY_DATA: connectpath %s, not supported.\n", 
                                        conn->connectpath));
@@ -2283,14 +2272,14 @@ static void call_nt_transact_ioctl(connection_struct *conn,
                if (max_data_count<data_count) {
                        DEBUG(0,("FSCTL_GET_SHADOW_COPY_DATA: max_data_count(%u) too small (%u) bytes needed!\n",
                                max_data_count,data_count));
-                       talloc_destroy(shadow_data->mem_ctx);
+                       TALLOC_FREE(shadow_data);
                        reply_nterror(req, NT_STATUS_BUFFER_TOO_SMALL);
                        return;
                }
 
                pdata = nttrans_realloc(ppdata, data_count);
                if (pdata == NULL) {
-                       talloc_destroy(shadow_data->mem_ctx);
+                       TALLOC_FREE(shadow_data);
                        reply_nterror(req, NT_STATUS_NO_MEMORY);
                        return;
                }
@@ -2323,7 +2312,7 @@ static void call_nt_transact_ioctl(connection_struct *conn,
                        }
                }
 
-               talloc_destroy(shadow_data->mem_ctx);
+               TALLOC_FREE(shadow_data);
 
                send_nt_replies(conn, req, NT_STATUS_OK, NULL, 0,
                                pdata, data_count);