From: Tom Tromey Date: Wed, 19 Feb 2020 14:50:21 +0000 (-0700) Subject: Remove useless NULL check in python.c X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d3c22fa82e2f9098ad5a0158a73f07db12426fff;p=binutils-gdb.git Remove useless NULL check in python.c I noticed that do_start_initialization, in python.c, checks the result of xmalloc. However, xmalloc cannot fail, so this check is useless. This patch also changes the code to use XNEWVEC. gdb/ChangeLog 2020-02-19 Tom Tromey * python/python.c (do_start_initialization): Use XNEWVEC. Remove NULL check. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0077a9824aa..e5df6bf48c9 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-02-19 Tom Tromey + + * python/python.c (do_start_initialization): Use XNEWVEC. Remove + NULL check. + 2020-02-19 Maciej W. Rozycki * NEWS: Mention RISC-V GNU/Linux GDBserver support. diff --git a/gdb/python/python.c b/gdb/python/python.c index 27d6042c618..fbbc159ede3 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -1679,12 +1679,7 @@ do_start_initialization () std::string oldloc = setlocale (LC_ALL, NULL); setlocale (LC_ALL, ""); progsize = strlen (progname.get ()); - progname_copy = (wchar_t *) xmalloc ((progsize + 1) * sizeof (wchar_t)); - if (!progname_copy) - { - fprintf (stderr, "out of memory\n"); - return false; - } + progname_copy = XNEWVEC (wchar_t, progsize + 1); count = mbstowcs (progname_copy, progname.get (), progsize + 1); if (count == (size_t) -1) {