GNU bug report logs - #11375
[PATCH] simplify/clarify xfns.c, replacing 4 lines with one

Previous Next

Package: emacs;

Reported by: Jim Meyering <jim <at> meyering.net>

Date: Sat, 28 Apr 2012 22:04:01 UTC

Severity: minor

Tags: patch

Done: Chong Yidong <cyd <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: bug-emacs <at> gnu.org
Subject: [PATCH] simplify/clarify xfns.c, replacing 4 lines with one
Date: Sun, 29 Apr 2012 00:02:03 +0200
2012-04-28  Jim Meyering  <meyering <at> redhat.com>

	simplify/clarify xfns.c, replacing 4 lines with one
	* src/xfns.c (x_window): Replace strlen+xmalloc+strncpy with xstrdup.

---
 src/xfns.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/xfns.c b/src/xfns.c
index 6f08ada..f7a80ce 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -2439,7 +2439,6 @@ x_window (struct frame *f, long window_prompting, int minibuffer_only)

   /* Do some needed geometry management.  */
   {
-    ptrdiff_t len;
     char *tem, shell_position[sizeof "=x++" + 4 * INT_STRLEN_BOUND (int)];
     Arg gal[10];
     int gac = 0;
@@ -2508,13 +2507,11 @@ x_window (struct frame *f, long window_prompting, int minibuffer_only)
         }
     }

-    len = strlen (shell_position) + 1;
     /* We don't free this because we don't know whether
        it is safe to free it while the frame exists.
        It isn't worth the trouble of arranging to free it
        when the frame is deleted.  */
-    tem = (char *) xmalloc (len);
-    strncpy (tem, shell_position, len);
+    tem = (char *) xstrdup (shell_position);
     XtSetArg (gal[gac], XtNgeometry, tem); gac++;
     XtSetValues (shell_widget, gal, gac);
   }
--
1.7.10.382.g62bc8




This bug report was last modified 13 years and 79 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.