David,
It looks like a compiler bug to me. Its treating the array as size 0.
My suggestion is to use a class/Tobject instead of record.
Rohit
On 25/08/2011 11:40 a.m., David Moorhouse (DUG) wrote:
I have the following code snippet
code
type
PConstArray = ^TConstArray;
TConstArray =
I have the following code snippet
code
type
PConstArray = ^TConstArray;
TConstArray = array of TVarRec;
function CreateConstArray(const Elements: array of const): TConstArray;
type
TLogType = (ltError, ltWarn, ltInfo);
PLogData = ^TLogData;
TLogData = record
LogType: TLogType;
Haven't got into the details of your problem, but here is an article
which goes into the details
of array of const.
http://rvelthuis.de/articles/articles-openarr.html
Hope it helps,
Cheers,
Colin
On 25 August 2011 09:40, David Moorhouse (DUG) del...@moorhouse.net.nz wrote:
I have the
I think your TLogData contains storage for an integer (TLogType, 4 bytes),
and a pointer to an array (4 bytes).
However, what you need is enough memory to store the entire array, not just
the pointer, so you should get the size of the array to get the correct
size.
On Thu, Aug 25, 2011 at 11:40
Thanks Colin
The TVarRec and open array stuff come from Rudy's page - very helpful too :)
D
Haven't got into the details of your problem, but here is an article
which goes into the details
of array of const.
http://rvelthuis.de/articles/articles-openarr.html
Hope it helps,
Cheers,
Thanks Robo
In my mind the memory layout looks like this (attempt at ascii art follows)
TLogData
- LogType = 4 bytes
- LogArgs - TConstArray - length = 4 bytes
- data pointer = 4 bytes
Regardless of the Length of the array, if I allocate 16 bytes the code
works
sure ok.
On Thu, 25 Aug 2011 11:57:26 +1200, Robo wrote:
I think
your TLogData contains storage for an integer (TLogType, 4 bytes), and a
pointer to an array (4 bytes).
However, what you need is enough memory to
store the entire array, not just the pointer, so you should get the size of
Just hard code 16 in David and we can discuss it we we do a code review
:-)
On Thu, Aug 25, 2011 at 12:36 PM, kal...@ihug.co.nz wrote:
sure ok.
On Thu, 25 Aug 2011 11:57:26 +1200, Robo robo...@gmail.com wrote:
I think your TLogData contains storage for an integer (TLogType, 4 bytes),