Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/menuc use calloc properly.



details:   https://anonhg.NetBSD.org/src/rev/93faa4857c5b
branches:  trunk
changeset: 452247:93faa4857c5b
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Jun 23 22:47:22 2019 +0000

description:
use calloc properly.

diffstat:

 usr.bin/menuc/menu_sys.def |  7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diffs (30 lines):

diff -r ddb6a70e1f2f -r 93faa4857c5b usr.bin/menuc/menu_sys.def
--- a/usr.bin/menuc/menu_sys.def        Sun Jun 23 22:46:53 2019 +0000
+++ b/usr.bin/menuc/menu_sys.def        Sun Jun 23 22:47:22 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: menu_sys.def,v 1.71 2019/06/23 11:22:48 martin Exp $   */
+/*     $NetBSD: menu_sys.def,v 1.72 2019/06/23 22:47:22 christos Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -674,10 +674,9 @@
        num_menus = DYN_INIT_NUM;
        while (num_menus < DYN_MENU_START)
                num_menus *= 2;
-       menu_list = malloc(sizeof *menu_list * num_menus);
+       menu_list = calloc(num_menus, sizeof *menu_list);
        if (menu_list == NULL)
                return 2;
-       (void)memset(menu_list, 0, sizeof *menu_list * num_menus);
        for (i = 0; i < DYN_MENU_START; i++)
                menu_list[i] = &menu_def[i];
 #endif
@@ -862,7 +861,7 @@
                        return OPT_NOMENU;
                m = menu_list[ix];
                if (m == NULL) {
-                       m = calloc(sizeof *m, 1);
+                       m = calloc(1, sizeof *m);
                        if (m == NULL)
                                return OPT_NOMENU;
                        menu_list[ix] = m;



Home | Main Index | Thread Index | Old Index