From owner-freebsd-hackers Tue Aug 1 18:28:48 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from mta5.rcsntx.swbell.net (mta5.rcsntx.swbell.net [151.164.30.29]) by hub.freebsd.org (Postfix) with ESMTP id 3CE8437B5A6 for ; Tue, 1 Aug 2000 18:28:43 -0700 (PDT) (envelope-from chris@holly.calldei.com) Received: from holly.calldei.com ([208.191.149.190]) by mta5.rcsntx.swbell.net (Sun Internet Mail Server sims.3.5.2000.01.05.12.18.p9) with ESMTP id <0FYN00GYB543V9@mta5.rcsntx.swbell.net> for freebsd-hackers@FreeBSD.ORG; Tue, 1 Aug 2000 20:21:39 -0500 (CDT) Received: (from chris@localhost) by holly.calldei.com (8.9.3/8.9.3) id UAA57403; Tue, 01 Aug 2000 20:19:31 -0500 (CDT envelope-from chris) Date: Tue, 01 Aug 2000 20:19:30 -0500 From: Chris Costello Subject: Re: malloc to arrays? In-reply-to: <200008020046.EAA01875@cicuta.babolo.ru> To: "."@babolo.ru Cc: freebsd-hackers@FreeBSD.ORG Reply-To: chris@calldei.com Message-id: <20000801201930.G54640@holly.calldei.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii User-Agent: Mutt/0.96.4i References: <200008020046.EAA01875@cicuta.babolo.ru> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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. -- |Chris Costello |Performance proven: It works through beta test. `----------------------------------------------- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message