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/6ddea2cc2664
branches:  trunk
changeset: 980706:6ddea2cc2664
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 3099a74a16ee -r 6ddea2cc2664 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