perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From do...@apache.org
Subject cvs commit: modperl-2.0/xs/Apache/SubProcess Apache__SubProcess.h
Date Tue, 18 Dec 2001 03:40:02 GMT
dougm       01/12/17 19:40:02

  Modified:    xs/Apache/SubProcess Apache__SubProcess.h
  Log:
  avoid calling av_len() more than once.
  switch from using av_len() to AvFILLp
  add av_items variable to avoid (-1 + 2) when there is no av_argv
  
  Revision  Changes    Path
  1.4       +9 -6      modperl-2.0/xs/Apache/SubProcess/Apache__SubProcess.h
  
  Index: Apache__SubProcess.h
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/xs/Apache/SubProcess/Apache__SubProcess.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Apache__SubProcess.h	2001/12/18 03:24:49	1.3
  +++ Apache__SubProcess.h	2001/12/18 03:40:02	1.4
  @@ -115,12 +115,15 @@
           const char **argv;
           int i;
           AV *av_argv;
  +        I32 len=-1, av_items=0;
           request_rec *r = modperl_xs_sv2request_rec(aTHX_ ST(0), NULL, cv);
           const char *command = (const char *)SvPV_nolen(ST(1));
   
           if (items == 3) {
               if (SvROK(ST(2)) && SvTYPE(SvRV(ST(2))) == SVt_PVAV) {
                   av_argv = (AV*)SvREFCNT_inc(SvRV(ST(2)));
  +                len = AvFILLp(av_argv);
  +                av_items = len+1;
               }
               else {
                   Perl_croak(aTHX_ usage);
  @@ -129,21 +132,21 @@
           else {
               av_argv = newAV();
           }
  -        
  +
           /* ap_os_create_privileged_process expects ARGV as char
            * **argv, with terminating NULL and the program itself as a
            * first item.
            */
  -        argv = apr_palloc(r->pool,
  -                          (3 + av_len(av_argv)) * sizeof(char *));
  +        argv = apr_palloc(r->pool, (av_items + 2) * sizeof(char *));
           argv[0] = command;
  -        for (i = 0; i <= av_len(av_argv); i++) {
  +        for (i = 0; i <= len; i++) {
               argv[i+1] = (const char *)SvPV_nolen(AvARRAY(av_argv)[i]);
           }
           argv[i+1] = NULL;
   #if 0
  -        for (i=0; i<=av_len(av_argv)+2; i++) {
  -            Perl_warn(aTHX_ "arg: %d %s\n", i, argv[i]);
  +        for (i=0; i<=len+2; i++) {
  +            Perl_warn(aTHX_ "arg: %d %s\n",
  +                      i, argv[i] ? argv[i] : "NULL");
           }
   #endif
           rc = modperl_spawn_proc_prog(r, command, &argv,
  
  
  

Mime
View raw message