s4-server: cleanup allocation of process models
authorAndrew Tridgell <tridge@samba.org>
Wed, 3 Nov 2010 09:57:38 +0000 (20:57 +1100)
committerAndrew Tridgell <tridge@samba.org>
Wed, 3 Nov 2010 10:40:52 +0000 (10:40 +0000)
Autobuild-User: Andrew Tridgell <tridge@samba.org>
Autobuild-Date: Wed Nov  3 10:40:52 UTC 2010 on sn-devel-104

source4/smbd/process_model.c
source4/smbd/process_model.h

index 7b18f583a7179d29e92256b8a9712026b1ab03ac..af12a7b8cb1f8f8486c00f740cc9e04488bc8ee6 100644 (file)
@@ -24,7 +24,7 @@
 
 /* the list of currently registered process models */
 static struct process_model {
-       struct model_ops *ops;
+       const struct model_ops *ops;
        bool initialised;
 } *models = NULL;
 static int num_models;
@@ -74,10 +74,8 @@ _PUBLIC_ const struct model_ops *process_model_startup(const char *model)
   The 'name' can be later used by other backends to find the operations
   structure for this backend.  
 */
-_PUBLIC_ NTSTATUS register_process_model(const void *_ops)
+_PUBLIC_ NTSTATUS register_process_model(const struct model_ops *ops)
 {
-       const struct model_ops *ops = _ops;
-
        if (process_model_byname(ops->name) != NULL) {
                /* its already registered! */
                DEBUG(0,("PROCESS_MODEL '%s' already registered\n", 
@@ -85,19 +83,17 @@ _PUBLIC_ NTSTATUS register_process_model(const void *_ops)
                return NT_STATUS_OBJECT_NAME_COLLISION;
        }
 
-       models = realloc_p(models, struct process_model, num_models+1);
+       models = talloc_realloc(NULL, models, struct process_model, num_models+1);
        if (!models) {
                smb_panic("out of memory in register_process_model");
        }
 
-       models[num_models].ops = smb_xmemdup(ops, sizeof(*ops));
-       models[num_models].ops->name = smb_xstrdup(ops->name);
+       models[num_models].ops = ops;
        models[num_models].initialised = false;
 
        num_models++;
 
-       DEBUG(3,("PROCESS_MODEL '%s' registered\n", 
-                ops->name));
+       DEBUG(3,("PROCESS_MODEL '%s' registered\n", ops->name));
 
        return NT_STATUS_OK;
 }
index b5790316ec2e55a107c9ac5f46c96e63dbaea7c7..4399d3689fbe16ec9edb58027ce7b3ce72789ab9 100644 (file)
@@ -80,7 +80,7 @@ struct process_model_critical_sizes {
 extern const struct model_ops single_ops;
 
 const struct model_ops *process_model_startup(const char *model);
-NTSTATUS register_process_model(const void *_ops);
+NTSTATUS register_process_model(const struct model_ops *ops);
 NTSTATUS process_model_init(struct loadparm_context *lp_ctx);
 
 #endif /* __PROCESS_MODEL_H__ */