From owner-freebsd-hackers Tue Aug 1 21: 9:11 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from peach.ocn.ne.jp (peach.ocn.ne.jp [210.145.254.87]) by hub.freebsd.org (Postfix) with ESMTP id 1E75F37B546 for ; Tue, 1 Aug 2000 21:09:05 -0700 (PDT) (envelope-from dcs@newsguy.com) Received: from newsguy.com (p02-dn03kiryunisiki.gunma.ocn.ne.jp [210.232.224.131]) by peach.ocn.ne.jp (8.9.1a/OCN/) with ESMTP id NAA16338; Wed, 2 Aug 2000 13:08:48 +0900 (JST) Message-ID: <39879ECA.61855D9D@newsguy.com> Date: Wed, 02 Aug 2000 13:08:42 +0900 From: "Daniel C. Sobral" X-Mailer: Mozilla 4.7 [en] (Win98; I) X-Accept-Language: en,pt-BR,ja MIME-Version: 1.0 To: chris@calldei.com Cc: .@babolo.ru, freebsd-hackers@FreeBSD.ORG Subject: Re: malloc to arrays? References: <200008020046.EAA01875@cicuta.babolo.ru> <20000801201930.G54640@holly.calldei.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Chris Costello wrote: > > On Wednesday, August 02, 2000, .@babolo.ru wrote: > > Sorry I have no other direction to ask this: > > I have declaration: > > > > u_int32_t *(tcpcash_addr[256]); > > > > and want malloc some memory for tcpcash_addr: > > > > tcpcash_addr = (typeof(tcpcash_addr))malloc(u_int32_t * 256 * n); > > > > and have an error: > > > > ra-sum.c:386: cast specifies array type > > *** Error code 1 > > Try this: > > u_int32_t *tcphash_haddr; > tcphash_addr = malloc(sizeof(*tcphash_addr) * 256); > > You shouldn't be casting malloc and I don't see any reason > to use *(foo[nmemb]) syntax. u_int32_t **tcphash_haddr; >From the code, it's a variable-sized array of fixed-sized arrays. -- Daniel C. Sobral (8-DCS) dcs@newsguy.com dcs@freebsd.org capo@white.bunnies.bsdconspiracy.net Satan was once an angel, Gates started by writing a BASIC interpreter. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message