From: | Jack York |
Date: | 14 Aug 2000 at 15:22:21 |
Subject: | Re: Passing a ptr |
Hello Allan
On 13-Aug-00, Allan Odgaard wrote:
> On 13-Aug-00, Niels de Koning wrote:
>
>>> It works fine as is but I when I place it in a function and call that
>>> function, it doesn't work at all. [...]
>> If you want to return a value from a function in the parameter list
>> you always have to add a level of indirection to that parameter, [...]
>
> Or actually return the value, e.g.:
>
> Array **MakeArray ()
> {
> Array **array = ...
> ...
> return array;
> }
Forgot about this option from focusing so hard on doing it the
other way. I gave this way a try and it worked except for a
problem with AllocPooled. From my calling function I have
array = MakeArray();
...do stuff with array
FreePooled (mempool, array, sizeof (mystruct * arraysize));
This line causes a poolwatch hit which says the size being
freed (4, sizeof (array) isn't what was allocated (sizeof (
mystruct * arraysize). If I remove this line and let DeletePool
handle it the program runs without hits. If I replace the
AllocPooled with AllocVec and then use FreeVec it works
fine. Any idea why this is happening?
Jack