CVS update [cvs1-11-x-branch]: /ccvs/windows-NT/

[email protected] 6 Jun 2005 21:33:27 -0000
Newsgroups gmane.comp.version-control.cvs.cvs
Message-ID <[email protected]>
Tag: cvs1-11-x-branch
User: conradpino
Date: 05/06/06 14:33:27

Modified:
 /ccvs/windows-NT/
  ChangeLog, run.c

Log:
 * windows-NT/run.c: Add "run_add_arg_p" and "run_arg_free_p" functions.
 Move cvs1-11-x-branch-last-merge to latest branch revision on the above
 and the corresponding ChangeLog file.

File Changes:

Directory: /ccvs/windows-NT/
============================

File [changed]: ChangeLog
Url: https://ccvs.cvshome.org/source/browse/ccvs/windows-NT/ChangeLog?r1=1.158.2.37&r2=1.158.2.38
Delta lines:  +4 -0
-------------------
--- ChangeLog	6 Jun 2005 21:32:51 -0000	1.158.2.37
+++ ChangeLog	6 Jun 2005 21:33:24 -0000	1.158.2.38
@@ -1,5 +1,9 @@
 2005-06-06  Conrad T. Pino  <[email protected]>
 
+	* run.c: Add "run_add_arg_p" and "run_arg_free_p" functions.
+
+2005-06-06  Conrad T. Pino  <[email protected]>
+
 	* run.c: Reverse patch committed 2005-05-27 by Conrad T. Pino.
 
 2005-05-28  Conrad T. Pino  <[email protected]>

File [changed]: run.c
Url: https://ccvs.cvshome.org/source/browse/ccvs/windows-NT/run.c?r1=1.16.8.5&r2=1.16.8.6
Delta lines:  +33 -10
---------------------
--- run.c	6 Jun 2005 21:32:51 -0000	1.16.8.5
+++ run.c	6 Jun 2005 21:33:24 -0000	1.16.8.6
@@ -44,23 +44,24 @@
 static int run_argc;
 static int run_argc_allocated;
 
+
+
 void
-run_setup (const char *prog)
+run_arg_free_p (int argc, char **argv)
 {
-    char *cp;
     int i;
+    for (i = 0; i < argc; i++)
+	free (argv[i]);
+}
 
+void
+run_setup (const char *prog)
+{
+    char *cp;
     char *run_prog;
 
     /* clean out any malloc'ed values from run_argv */
-    for (i = 0; i < run_argc; i++)
-    {
-	if (run_argv[i])
-	{
-	    free (run_argv[i]);
-	    run_argv[i] = (char *) 0;
-	}
-    }
+    run_arg_free_p (run_argc, run_argv);
     run_argc = 0;
 
     run_prog = xstrdup (prog);
@@ -79,6 +80,28 @@
     run_add_arg (s);
 }
 
+
+
+void
+run_add_arg_p (iargc, iarg_allocated, iargv, s)
+    int *iargc;
+    size_t *iarg_allocated;
+    char ***iargv;
+    const char *s;
+{
+    /* allocate more argv entries if we've run out */
+    if (*iargc >= *iarg_allocated)
+    {
+	*iarg_allocated += 50;
+	*iargv = xrealloc (*iargv, *iarg_allocated * sizeof (char **));
+    }
+
+    if (s)
+	(*iargv)[(*iargc)++] = xstrdup (s);
+    else
+	(*iargv)[*iargc] = NULL;	/* not post-incremented on purpose! */
+}
+
 /* Return a malloc'd copy of s, with double quotes around it.  */
 static char *
 quote (const char *s)