svn commit: r286617 - head/usr.bin/patch

Xin LI delphij at FreeBSD.org
Tue Aug 11 05:58:34 UTC 2015


Author: delphij
Date: Tue Aug 11 05:58:33 2015
New Revision: 286617
URL: https://svnweb.freebsd.org/changeset/base/286617

Log:
  Use __DECONST instead of doing strdup/free.
  
  Suggested by:	ed
  MFC after:	2 weeks

Modified:
  head/usr.bin/patch/inp.c

Modified: head/usr.bin/patch/inp.c
==============================================================================
--- head/usr.bin/patch/inp.c	Tue Aug 11 05:51:00 2015	(r286616)
+++ head/usr.bin/patch/inp.c	Tue Aug 11 05:58:33 2015	(r286617)
@@ -219,8 +219,8 @@ plan_a(const char *filename)
 					say("Comparing file %s to default "
 					    "RCS version...\n", filename);
 
-				argp[0] = strdup(RCSDIFF);
-				argp[1] = strdup(filename);
+				argp[0] = __DECONST(char *, RCSDIFF);
+				argp[1] = __DECONST(char *, filename);
 				posix_spawn_file_actions_init(&file_actions);
 				posix_spawn_file_actions_addopen(&file_actions,
 				    STDOUT_FILENO, _PATH_DEVNULL, O_WRONLY, 0);
@@ -234,17 +234,15 @@ plan_a(const char *filename)
 				} else
 					fatal("posix_spawn: %s\n", strerror(errno));
 				posix_spawn_file_actions_destroy(&file_actions);
-				free(argp[1]);
-				free(argp[0]);
 			}
 
 			if (verbose)
 				say("Checking out file %s from RCS...\n",
 				    filename);
 
-			argp[0] = strdup(CHECKOUT);
-			argp[1] = strdup("-l");
-			argp[2] = strdup(filename);
+			argp[0] = __DECONST(char *, CHECKOUT);
+			argp[1] = __DECONST(char *, "-l");
+			argp[2] = __DECONST(char *, filename);
 			if (posix_spawn(&pid, CHECKOUT, NULL, NULL, argp,
 			    NULL) == 0) {
 				pid = waitpid(pid, &pstat, 0);
@@ -254,9 +252,6 @@ plan_a(const char *filename)
 					    filename);
 			} else
 				fatal("posix_spawn: %s\n", strerror(errno));
-			free(argp[2]);
-			free(argp[1]);
-			free(argp[0]);
 		} else if (statfailed) {
 			fatal("can't find %s\n", filename);
 		}


More information about the svn-src-head mailing list