Source-Changes-HG archive

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

[src/trunk]: src/tests/lib/libcurses/director Simplify to avoid copy based on...



details:   https://anonhg.NetBSD.org/src/rev/58caf0351f7d
branches:  trunk
changeset: 952714:58caf0351f7d
user:      joerg <joerg%NetBSD.org@localhost>
date:      Mon Feb 15 15:55:50 2021 +0000

description:
Simplify to avoid copy based on the size of the source.

diffstat:

 tests/lib/libcurses/director/testlang_parse.y |  6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diffs (22 lines):

diff -r 569f75ffd22a -r 58caf0351f7d tests/lib/libcurses/director/testlang_parse.y
--- a/tests/lib/libcurses/director/testlang_parse.y     Mon Feb 15 15:53:49 2021 +0000
+++ b/tests/lib/libcurses/director/testlang_parse.y     Mon Feb 15 15:55:50 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/*     $NetBSD: testlang_parse.y,v 1.48 2021/02/15 07:06:27 rillig Exp $       */
+/*     $NetBSD: testlang_parse.y,v 1.49 2021/02/15 15:55:50 joerg Exp $        */
 
 /*-
  * Copyright 2009 Brett Lymn <blymn%NetBSD.org@localhost>
@@ -1388,10 +1388,8 @@
                free(input_str);
        }
 
-       if ((input_str = malloc(strlen(s) + 1)) == NULL)
+       if ((input_str = strdup(s)) == NULL)
                err(2, "Cannot allocate memory for input string");
-
-       strlcpy(input_str, s, strlen(s) + 1);
 }
 
 static void



Home | Main Index | Thread Index | Old Index