Found this line under the Blitz.mod in array.c file:
This is part of the `new array` code, and allocates apparently a single block of memory for each `dimension`, unless I'm not interpreting it right - so maybe each dimension is stored together as one block of memory, and for a 1 dimensional array there is just one single block?
However, a look at blitz_memory.c is interesting, particularly in the bbGCMemAlloc subroutine.
e.g.
MAXSIZE is 256, so likelyhood is that bbMemAlloc will be called..., which calls:
So now we're into malloc(). I'm guessing therefore that you get a solid block of memory that's contiguous, at least for each dimension.
You'd think that it's supposed to be safe to get a pointer to the first element of the array and then access all the elements with the pointer, which would be seriously compromized if the contiguous indexes were split up into multiple memory sections. I would think Mark would've designed it so that where there are natural breaks, ie where you have an array of arrays or an array with more than one dimension, that the memory for those extra arrays or dimensions would be separate areas with their own `base pointers`. I don't think Mark would've overlooked the possibility that people would try to access array elements with pointers, which is a language feature, only to have it create creashes or array bounds exceptions for no reason that the user can find apparent.
Anyone know different?
arr=(BBArray*)bbGCAlloc( BBARRAYSIZE(size,dims),(BBGCPool*)&bbArrayClass );
This is part of the `new array` code, and allocates apparently a single block of memory for each `dimension`, unless I'm not interpreting it right - so maybe each dimension is stored together as one block of memory, and for a 1 dimensional array there is just one single block?
However, a look at blitz_memory.c is interesting, particularly in the bbGCMemAlloc subroutine.
e.g.
if( size>(MAXSIZE-SIZEALIGN) ){ p=bbMemAlloc( size );
MAXSIZE is 256, so likelyhood is that bbMemAlloc will be called..., which calls:
b=malloc(size+4+SIZEALIGN);
So now we're into malloc(). I'm guessing therefore that you get a solid block of memory that's contiguous, at least for each dimension.
You'd think that it's supposed to be safe to get a pointer to the first element of the array and then access all the elements with the pointer, which would be seriously compromized if the contiguous indexes were split up into multiple memory sections. I would think Mark would've designed it so that where there are natural breaks, ie where you have an array of arrays or an array with more than one dimension, that the memory for those extra arrays or dimensions would be separate areas with their own `base pointers`. I don't think Mark would've overlooked the possibility that people would try to access array elements with pointers, which is a language feature, only to have it create creashes or array bounds exceptions for no reason that the user can find apparent.
Anyone know different?