bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] maint: tighten up superfluous code


From: Jim Meyering
Subject: [PATCH] maint: tighten up superfluous code
Date: Mon, 20 Jun 2011 07:23:29 +0200

While auditing malloc-related code, I couldn't miss this:

>From 0a2b8e82f56f43c05d94a361a356f1dee35c5a34 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sun, 19 Jun 2011 22:57:37 +0200
Subject: [PATCH] maint: tighten up superfluous code

* src/main.c (parse_grep_colors): Use xstrdup in place of xmalloc,
a useless test, strlen, and strcpy.
---
 src/main.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/src/main.c b/src/main.c
index f964adb..4e01a17 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1682,10 +1682,7 @@ parse_grep_colors (void)
     return;

   /* Work off a writable copy.  */
-  q = xmalloc(strlen(p) + 1);
-  if (q == NULL)
-    return;
-  strcpy(q, p);
+  q = xstrdup(p);

   name = q;
   val = NULL;
--
1.7.6.rc2.4.g36bfb.dirty



reply via email to

[Prev in Thread] Current Thread [Next in Thread]