Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-12

Setlength

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

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

Reply by email

Jonas Maebe
to Carsten Bager
Carsten Bager wrote 5 lines
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

Reply by email

Jonas Maebe
Flávio Etrusco wrote 21 lines
On Fri, Dec 4, 2009 at 12:32 PM, Jonas Maebe < > 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

Reply by email