[svn:mod_parrot] r508 - mod_parrot/trunk/src

[email protected] Sun, 30 Nov 2008 08:34:34 -0800 (PST)
Newsgroups perl.cvs.mod_parrot
Message-ID <[email protected]>
Author: jhorwitz
Date: Sun Nov 30 08:34:34 2008
New Revision: 508

Modified:
   mod_parrot/trunk/src/module.c

Log:
allow modules with no directives


Modified: mod_parrot/trunk/src/module.c
==============================================================================
--- mod_parrot/trunk/src/module.c	(original)
+++ mod_parrot/trunk/src/module.c	Sun Nov 30 08:34:34 2008
@@ -336,20 +336,24 @@
     module **modpp;
     modparrot_context *ctxp = get_interp_ctx(interp);
     server_rec *s = ctxp->s;
-    
 
-    if (!cmd_array) return(NULL);
-    num = Parrot_PMC_get_intval(interp, cmd_array);
-    if (!num) return(NULL);
+    /* custom directives are optional */
+    command_rec *cmds = NULL;
+    if (PMC_IS_NULL(cmd_array)) {
+        num = 0;
+    }
+    else {
+        num = Parrot_PMC_get_intval(interp, cmd_array);
+        if (num) {
+            cmds = (command_rec *)apr_pcalloc(p, sizeof(command_rec)*(num+1));
+        }
+    }
 
     /* save for later use by register_meta_hooks */
     our_server = ctxp->s;
 
     mpcfg = ap_get_module_config(s->module_config, &parrot_module);
 
-    command_rec *cmds =
-        (command_rec *)apr_pcalloc(p, sizeof(command_rec)*(num+1));
-
     for (i = 0; i < num; i++) {
         Parrot_PMC val;
         Parrot_PMC cmd;