arrays && functions && pointers

Regan Heath regan at netwin.co.nz
Mon Jun 19 15:43:54 PDT 2006


On Mon, 19 Jun 2006 17:41:47 +0000 (UTC), MM <MM_member at pathlink.com>  
wrote:
> I did your insanity test.. And here there was no significant speed  
> difference
> (also none with -O)

Thanks.

> But why do you use:
> arr = cast(TILE (*)[TILEW][TILEH])calloc(TILEW*TILEH,TILE.sizeof);
>
> Was that only for the size limit?

Yes. With TILEW && TILEH == 1000 the array would not fit on the stack, it  
gave a stack overflow error starting the program.

> I just used:
> TILE[TILEW][TILEH] arr;
>
> TILEW && TILEH == 250
>
> (Still the same speed)

I wanted to make the array big enough that stacking/copying it for each  
function call would be very noticable.

> Why this is the limit I don't understand, 16MB should be the limit,  
> right?

I don't actually know what the stack limit it. For this test it doesn't  
really matter what the exact value is, the very fact that the program runs  
proves it's not stacking the entire array for each call to the function  
which is all I was trying to discover.

Thanks again for checking this for me.

Regan



More information about the Digitalmars-d-learn mailing list