Module Name:    src
Committed By:   alnsn
Date:           Tue Jan 31 20:40:09 UTC 2012

Modified Files:
        src/sys/kern: subr_pcq.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/kern/subr_pcq.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/subr_pcq.c
diff -u src/sys/kern/subr_pcq.c:1.5 src/sys/kern/subr_pcq.c:1.6
--- src/sys/kern/subr_pcq.c:1.5	Tue Jan 31 19:11:37 2012
+++ src/sys/kern/subr_pcq.c	Tue Jan 31 20:40:09 2012
@@ -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 @@ pcq_create(size_t nitems, km_flag_t kmfl
 
 	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;
 	}

Reply via email to