Setlength

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Setlength

Carsten Bager
I have 2 lines of code
1 I allocate memory
2 I read from the screen (Nano-X) and save it in the "BitMapArray".

Can I do this or can I not be sure that the memory is in one block.


setlength(BitMapArray,Width*Height);
GrReadArea(TNxWindow(window).w,Left,Top,Width,Height,@BitMapArray[0]);

Carsten

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Setlength

Jonas Maebe-2

On 04 Dec 2009, at 14:57, Carsten Bager wrote:

> I have 2 lines of code
> 1 I allocate memory
> 2 I read from the screen (Nano-X) and save it in the "BitMapArray".
>
> Can I do this or can I not be sure that the memory is in one block.

I have no idea whether that is guaranteed. It is currently implemented  
in that way, but I don't know whether that is an implementation detail  
or guaranteed behaviour.


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Setlength

Jonas Maebe-2

On 04 Dec 2009, at 17:03, Flávio Etrusco wrote:

> On Fri, Dec 4, 2009 at 12:32 PM, Jonas Maebe <[hidden email]
> > wrote:
>>
>> On 04 Dec 2009, at 14:57, Carsten Bager wrote:
>>
>>> I have 2 lines of code
>>> 1 I allocate memory
>>> 2 I read from the screen (Nano-X) and save it in the "BitMapArray".
>>>
>>> Can I do this or can I not be sure that the memory is in one block.
>>
>> I have no idea whether that is guaranteed. It is currently  
>> implemented in
>> that way, but I don't know whether that is an implementation detail  
>> or
>> guaranteed behaviour.
>>
>
> By "in one block" does he mean "contiguous user-space addresses"?
> If so, I don't understand your answer. How would a non-contiguous
> allocation work?

There are many implementations of dynamic array-like structures that  
externally behave like an array, but which internally divide the array  
over multiple allocations. The reason is that contiguous virtual  
memory space is not infinite either, especially not in 32  
applications. Indexing is then internally performed using 2 (first  
select the subarray, then the element) or more steps.


Jonas_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal