2009/10/8 Jonas Maebe :
>
> Also with understanding how dynamic arrays and/or move work. Dynamic arrays
> are reference counted pointers to data blobs. sizeof(dynamic_array_var) =
> sizeof(pointer), always, and regardless of the length of the array. It's
> like sizeof(class) = sizeof(ansistring) =
2009/10/8 Vincent Snijders :
>
> Working with pointers, if you don't get it, maybe just use a loop.
I have to admit. After working for so long with RDBMS API's, I got
quite rusty with the more low level file reading, record structures
and pointer arithmetic. Database desktop applications clearly
On 08 Oct 2009, at 16:18, Graeme Geldenhuys wrote:
2009/10/8 Jonas Maebe :
SetLength(tocarray, _Header.ntoc);
p := _Data + _Header.tocoffsetsstart;
Move(p, tocarray, SizeOf(tocarray));
This has to be
move(p^, tocarray^, length(tocarray)*sizeof(tocarray[0]));
Zitat von Graeme Geldenhuys :
[...]
* ntoc = number of entries in the array. Each entry is a LongWord (or
Int32 in the code below)
* tocarray is my local array that gets populated with information from
the file, using the Move() procedure.
* tocoffsetsstart is the starting offset of the TOC arr
Graeme Geldenhuys schreef:
2009/10/8 Jonas Maebe :
SetLength(tocarray, _Header.ntoc);
p := _Data + _Header.tocoffsetsstart;
Move(p, tocarray, SizeOf(tocarray));
This has to be
move(p^, tocarray^, length(tocarray)*sizeof(tocarray[0]));
^
This gives a compile
2009/10/8 Jonas Maebe :
> Also, as you can see the program does not really depend on the data being
> actually stored in a dynamic array. So you could just as well use "tocarray:
> ^Int32" and assign it the value of p (as you pretty much did until now).
Ah! That is what I wanted to do in the first
>
> Move(p, tocarray[0], SizeOf(tocarray));
> This causes an Access Violation at runtime.
>
This should not cause as RAV. You must call
SetLength(toarray,SizeOfMemory) and also don't use SizeOf(tocarray)
use Length(tocarray)*SizeOf(What ever the element is))
_
2009/10/8 Jonas Maebe :
>> SetLength(tocarray, _Header.ntoc);
>> p := _Data + _Header.tocoffsetsstart;
>> Move(p, tocarray, SizeOf(tocarray));
>
> This has to be
>
> move(p^, tocarray^, length(tocarray)*sizeof(tocarray[0]));
^
This gives a compiler error. Illegal
On 08 Oct 2009, at 15:58, Alexey Voytsehovich wrote:
Thursday, October 8, 2009, 4:51:34 PM, you wrote:
// Finalize(tocarray);<--- doesn't work
Finalize(tocarray, _header.ntoc); <--- doesn't work
tocarray := nil; <--- doesn't wor
Graeme Geldenhuys schreef:
Hi,
--
procedure THelpFile.ReadContents;
var
Topic: TTopic;
EntryIndex: longint;
pEntry: pTTOCEntryStart;
tocarray: array of Int32;
p: PByte;
begin
_Topics.Capacity := _Header.ntoc;
SetLength(tocarray, _Header.ntoc);
Hello Graeme,
Thursday, October 8, 2009, 4:51:34 PM, you wrote:
> tocarray: array of Int32;
> p: PByte;
> begin
> _Topics.Capacity := _Header.ntoc;
> SetLength(tocarray, _Header.ntoc);
> // Finalize(tocarray);<--- doesn't work
> Finalize(tocarray, _header.ntoc);
On 08 Oct 2009, at 15:51, Graeme Geldenhuys wrote:
procedure THelpFile.ReadContents;
var
Topic: TTopic;
EntryIndex: longint;
pEntry: pTTOCEntryStart;
tocarray: array of Int32;
p: PByte;
begin
_Topics.Capacity := _Header.ntoc;
SetLength(tocarray, _Header.ntoc);
p := _Data + _Header.toco
Hi,
I enabled heaptrc and it reported on block of memory not being freed.
I tracked it down to the following method in my code. I have tried
everything I can think of, but the memory leak still persists. Could
anybody help me please.
A quick description of what this code does. I'm reading content
13 matches
Mail list logo