Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Revert to more readable but non-standard use of off...



details:   https://anonhg.NetBSD.org/src/rev/12c19d462b44
branches:  trunk
changeset: 773355:12c19d462b44
user:      alnsn <alnsn%NetBSD.org@localhost>
date:      Tue Jan 31 20:40:09 2012 +0000

description:
Revert to more readable but non-standard use of offsetof to calculate
a size of a structure with a flexible array member.

diffstat:

 sys/kern/subr_pcq.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 250909bf9785 -r 12c19d462b44 sys/kern/subr_pcq.c
--- a/sys/kern/subr_pcq.c       Tue Jan 31 20:30:15 2012 +0000
+++ b/sys/kern/subr_pcq.c       Tue Jan 31 20:40:09 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_pcq.c,v 1.5 2012/01/31 19:11:37 alnsn Exp $       */
+/*     $NetBSD: subr_pcq.c,v 1.6 2012/01/31 20:40:09 alnsn Exp $       */
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_pcq.c,v 1.5 2012/01/31 19:11:37 alnsn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pcq.c,v 1.6 2012/01/31 20:40:09 alnsn Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -199,7 +199,7 @@
 
        KASSERT(nitems > 0 || nitems <= 0xffff);
 
-       pcq = kmem_zalloc(sizeof(pcq_t) + sizeof(void *[nitems]), kmflags);
+       pcq = kmem_zalloc(offsetof(pcq_t, pcq_items[nitems]), kmflags);
        if (pcq == NULL) {
                return NULL;
        }



Home | Main Index | Thread Index | Old Index