Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 01 Aug 2000 20:19:30 -0500
From:      Chris Costello <chris@calldei.com>
To:        "."@babolo.ru
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: malloc to arrays?
Message-ID:  <20000801201930.G54640@holly.calldei.com>
In-Reply-To: <200008020046.EAA01875@cicuta.babolo.ru>
References:  <200008020046.EAA01875@cicuta.babolo.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <chris@calldei.com>
|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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000801201930.G54640>