On 04.04.2017 15:40, Ryan Joseph wrote: > >> On Apr 4, 2017, at 7:17 PM, Sven Barth via fpc-pascal >> <fpc-pascal@lists.freepascal.org> wrote: >> >> If you want continuous memory areas you need to use static arrays or develop >> your own dynamic data structure that uses array properties. >> >> > > I’m glad I asked because of arrays of pointers is bad news for performance. > Does SetLength on a single level dynamic array not even allocate a continuous > block of memory? I could use GetMem and array[0..0] but it seems like dynamic > arrays should do basically that anyways if they’re not nested.
SetLength() allocates a single block of memory, cause array access is ordinary pointer arithmetic. However if you have an array of array then the first array stores a pointer to each sub array. E.g. the following would be valid, too: === code begin === var arr: array of array of Integer; begin SetLength(arr, 10, 10); SetLength(arr[3], 5); arr[6] := Nil; SetLength(arr[8], 15); end. === code end === Regards, Sven _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal