Source-Changes-HG archive

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

[src/trunk]: src/lib/libcurses __makenew: use calloc to get zeroed memory for...



details:   https://anonhg.NetBSD.org/src/rev/edf3312b7297
branches:  trunk
changeset: 364467:edf3312b7297
user:      uwe <uwe%NetBSD.org@localhost>
date:      Sat Mar 26 16:03:02 2022 +0000

description:
__makenew: use calloc to get zeroed memory for window contents.

PR lib/56767.

diffstat:

 lib/libcurses/newwin.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (36 lines):

diff -r 9d75104a9265 -r edf3312b7297 lib/libcurses/newwin.c
--- a/lib/libcurses/newwin.c    Sat Mar 26 15:39:58 2022 +0000
+++ b/lib/libcurses/newwin.c    Sat Mar 26 16:03:02 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: newwin.c,v 1.64 2022/01/25 03:05:06 blymn Exp $        */
+/*     $NetBSD: newwin.c,v 1.65 2022/03/26 16:03:02 uwe Exp $  */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)newwin.c   8.3 (Berkeley) 7/27/94";
 #else
-__RCSID("$NetBSD: newwin.c,v 1.64 2022/01/25 03:05:06 blymn Exp $");
+__RCSID("$NetBSD: newwin.c,v 1.65 2022/03/26 16:03:02 uwe Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -275,7 +275,7 @@
                free(win);
                return NULL;
        }
-       if ((win->lspace = malloc(nlines * sizeof(__LINE))) == NULL) {
+       if ((win->lspace = calloc(nlines, sizeof(__LINE))) == NULL) {
                free(win->alines);
                free(win);
                return NULL;
@@ -288,7 +288,7 @@
                 * Allocate window space in one chunk.
                 */
                if ((win->wspace =
-                       malloc(ncols * nlines * sizeof(__LDATA))) == NULL) {
+                       calloc(ncols * nlines, sizeof(__LDATA))) == NULL) {
                        free(win->lspace);
                        free(win->alines);
                        free(win);



Home | Main Index | Thread Index | Old Index