From: | Jack York |
Date: | 18 Aug 2000 at 13:09:19 |
Subject: | Re: Passing a ptr |
Hello Allan
On 18-Aug-00, Allan Odgaard wrote:
>>>> if ( ! *((array[i]) = (mystruct *) AllocVec (sizeof
>>>> (mystruct)))
>>> ^ - this seems to be wrong...
>>>
>>> What you do is check if the first field of the allocated chunk is
>>> non-null.
>> I'm not sure I understand this Allan for a couple of reasons. Are
>> you saying that if I end up with an array of 10 structs that I should
>> only check if array[0] was allocated?
>
> No. What I say is you should check Array[0], Array[1], ... but what you
> do check is *Array[0], *Array[1], ... -- i.e. rather than checking the
> 10 chunks you allocate, you check the first field of each of the 10
> chunks. All you need is remove the star that I underlined above
> (you'll need to press amiga-t to disable styles in YAM to read it
> properly).
Umm, below is the code I posted that you responded to. It already
doesn't have a star where you indicated so that doesn't seem to
be the problem. :(
BOOL MakeArray (mystruct ***array, LONG arraysize)
{
if (**array = (mystruct ***) AllocVec ( arraysize * sizeof (mystruct
*)))
{
for (i = 0; i < arraysize; i++)
{
if ( ! *((array[i]) = (mystruct *) AllocVec (sizeof (mystruct)))
break;
Jack