Source-Changes-HG archive

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

[src/trunk]: src calloc() arg mistake. it's (nelem, size). from openbsd



details:   https://anonhg.NetBSD.org/src/rev/00cda66e053b
branches:  trunk
changeset: 535207:00cda66e053b
user:      itojun <itojun%NetBSD.org@localhost>
date:      Mon Aug 12 02:37:26 2002 +0000

description:
calloc() arg mistake.  it's (nelem, size).  from openbsd

diffstat:

 bin/csh/dir.c       |  10 +++++-----
 bin/csh/file.c      |   6 +++---
 games/monop/cards.c |   6 +++---
 3 files changed, 11 insertions(+), 11 deletions(-)

diffs (99 lines):

diff -r 6723153c4551 -r 00cda66e053b bin/csh/dir.c
--- a/bin/csh/dir.c     Mon Aug 12 02:34:12 2002 +0000
+++ b/bin/csh/dir.c     Mon Aug 12 02:37:26 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.19 2002/05/25 23:29:16 wiz Exp $ */
+/* $NetBSD: dir.c,v 1.20 2002/08/12 02:37:26 itojun Exp $ */
 
 /*-
  * Copyright (c) 1980, 1991, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)dir.c      8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: dir.c,v 1.19 2002/05/25 23:29:16 wiz Exp $");
+__RCSID("$NetBSD: dir.c,v 1.20 2002/08/12 02:37:26 itojun Exp $");
 #endif
 #endif /* not lint */
 
@@ -130,7 +130,7 @@
        }
     }
 
-    dp = (struct directory *)xcalloc(sizeof(struct directory), 1);
+    dp = (struct directory *)xcalloc(1, sizeof(struct directory));
     dp->di_name = Strsave(cp);
     dp->di_count = 0;
     dhead.di_next = dhead.di_prev = dp;
@@ -365,7 +365,7 @@
     }
     else
        cp = dfollow(*v);
-    dp = (struct directory *)xcalloc(sizeof(struct directory), 1);
+    dp = (struct directory *)xcalloc(1, sizeof(struct directory));
     dp->di_name = cp;
     dp->di_count = 0;
     dp->di_next = dcwd->di_next;
@@ -512,7 +512,7 @@
        Char *ccp;
 
        ccp = dfollow(*v);
-       dp = (struct directory *)xcalloc(sizeof(struct directory), 1);
+       dp = (struct directory *)xcalloc(1, sizeof(struct directory));
        dp->di_name = ccp;
        dp->di_count = 0;
        dp->di_prev = dcwd;
diff -r 6723153c4551 -r 00cda66e053b bin/csh/file.c
--- a/bin/csh/file.c    Mon Aug 12 02:34:12 2002 +0000
+++ b/bin/csh/file.c    Mon Aug 12 02:37:26 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: file.c,v 1.19 2002/05/25 23:29:16 wiz Exp $ */
+/* $NetBSD: file.c,v 1.20 2002/08/12 02:37:26 itojun Exp $ */
 
 /*-
  * Copyright (c) 1980, 1991, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)file.c     8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: file.c,v 1.19 2002/05/25 23:29:16 wiz Exp $");
+__RCSID("$NetBSD: file.c,v 1.20 2002/08/12 02:37:26 itojun Exp $");
 #endif
 #endif /* not lint */
 
@@ -532,7 +532,7 @@
                break;
            }
            if (items == NULL)
-               items = (Char **)xcalloc(sizeof(items[0]), MAXITEMS);
+               items = (Char **)xcalloc(MAXITEMS, sizeof(items[0]));
            items[numitems] = (Char *)xmalloc((size_t) (Strlen(entry) + 1) *
                sizeof(Char));
            copyn(items[numitems], entry, MAXNAMLEN);
diff -r 6723153c4551 -r 00cda66e053b games/monop/cards.c
--- a/games/monop/cards.c       Mon Aug 12 02:34:12 2002 +0000
+++ b/games/monop/cards.c       Mon Aug 12 02:37:26 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cards.c,v 1.11 1999/12/30 01:40:08 simonb Exp $        */
+/*     $NetBSD: cards.c,v 1.12 2002/08/12 02:38:13 itojun Exp $        */
 
 /*
  * Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)cards.c    8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: cards.c,v 1.11 1999/12/30 01:40:08 simonb Exp $");
+__RCSID("$NetBSD: cards.c,v 1.12 2002/08/12 02:38:13 itojun Exp $");
 #endif
 #endif /* not lint */
 
@@ -101,7 +101,7 @@
        int r1, r2;
        int i;
 
-       dp->offsets = (off_t *) calloc(sizeof (off_t), dp->num_cards);
+       dp->offsets = (off_t *) calloc(dp->num_cards, sizeof (off_t));
        if (dp->offsets == NULL)
                errx(1, "out of memory");
        if (fread(dp->offsets, sizeof(off_t), dp->num_cards, deckf) !=



Home | Main Index | Thread Index | Old Index