Don't copy the rpc function pointers
authorVolker Lendecke <vl@samba.org>
Sun, 9 Dec 2007 18:46:06 +0000 (19:46 +0100)
committerJeremy Allison <jra@samba.org>
Sun, 9 Dec 2007 19:11:21 +0000 (11:11 -0800)
This actually shows up in a valgrind massif run with 4.1% of allocated memory.
I don't see why we would have to make a copy here.

Metze?

source/rpc_server/srv_pipe.c

index 49ffcf13a64265921ce20b086a1c919d6547a12c..5ede0c93f4ad396e266faa80725f91e10dcbfc94 100644 (file)
@@ -714,7 +714,7 @@ struct rpc_table {
                const char *clnt;
                const char *srv;
        } pipe;
-       struct api_struct *cmds;
+       const struct api_struct *cmds;
        int n_cmds;
 };
 
@@ -1075,12 +1075,8 @@ NTSTATUS rpc_pipe_register_commands(int version, const char *clnt, const char *s
         ZERO_STRUCTP(rpc_entry);
         rpc_entry->pipe.clnt = SMB_STRDUP(clnt);
         rpc_entry->pipe.srv = SMB_STRDUP(srv);
-        rpc_entry->cmds = SMB_REALLOC_ARRAY(rpc_entry->cmds, struct api_struct, rpc_entry->n_cmds + size);
-       if (!rpc_entry->cmds) {
-               return NT_STATUS_NO_MEMORY;
-       }
-        memcpy(rpc_entry->cmds + rpc_entry->n_cmds, cmds, size * sizeof(struct api_struct));
-        rpc_entry->n_cmds += size;
+        rpc_entry->cmds = cmds;
+        rpc_entry->n_cmds = size;
         
         return NT_STATUS_OK;
 }