Re: [fpc-pascal]Pointer Help

2003-02-10 Thread Jonas Maebe
On zondag, feb 9, 2003, at 15:06 Europe/Brussels, Anton Tichawa wrote: That's exactly what I meant: I'm not sure if fpc is able to keep track of the destruction of the strings in case of AnsiString. It is, as long as the type of the variable is clear when getmem/freemem is called (getmem also

Re: [fpc-pascal]Pointer Help

2003-02-09 Thread James Mills
On Sun, Feb 09, 2003 at 03:42:29PM +0100, Anton Tichawa wrote: > Hi, > > > But getMem and reAllocMem allocate a number of bytes on the heap, > > wouldn't you have to free that number of bytes using freeMem(pointer, n) > > ? > > No, Free Pascal keeps track of the allocated size for a pointer creat

Re: [fpc-pascal]Pointer Help

2003-02-09 Thread Anton Tichawa
Hi, > But getMem and reAllocMem allocate a number of bytes on the heap, > wouldn't you have to free that number of bytes using freeMem(pointer, n) > ? No, Free Pascal keeps track of the allocated size for a pointer created with GetMem/ReallocMem. They need this information for heap management, s

Re: [fpc-pascal]Pointer Help

2003-02-09 Thread James Mills
On Sun, Feb 09, 2003 at 03:12:07PM +0100, Anton Tichawa wrote: > On Sunday 09 February 2003 12:54, you wrote: > > > freeMem(tmpStrings, sizeOf(String) * (N)); > > No, only: > > freeMem(tmpStrings); But getMem and reAllocMem allocate a number of bytes on the heap, wouldn't you have to free that

Re: [fpc-pascal]Pointer Help

2003-02-09 Thread Anton Tichawa
On Sunday 09 February 2003 12:54, you wrote: > freeMem(tmpStrings, sizeOf(String) * (N)); No, only: freeMem(tmpStrings); Read the Manual - Free Pascal Programmer's Manual, Section 4.5, "Writing Your Own Memory Manager" - because that's what you're actually doing. HTH Anton Tichawa. --

Re: [fpc-pascal]Pointer Help

2003-02-09 Thread Anton Tichawa
Hello, James! That's exactly what I meant: I'm not sure if fpc is able to keep track of the destruction of the strings in case of AnsiString. You might check it by displaying the total free memory before and after the deallocation of tmpStrings. But one of the developers might answer this quest

Re: [fpc-pascal]Pointer Help

2003-02-09 Thread James Mills
On Sun, Feb 09, 2003 at 02:22:55PM +0100, Anton Tichawa wrote: > Hello, James! > > I found an error at GetMem / ReAllocMem: Your code: > > getMem(tmpStrings, 100); > {reAllocMem(tmpStrings, (I + 1));} > > reserves 100 or (I + 1) BYTES, but you need space for 100 or (I + 1) > STRINGS, i. e.

Re: [fpc-pascal]Pointer Help

2003-02-09 Thread James Mills
On Sun, Feb 09, 2003 at 02:22:55PM +0100, Anton Tichawa wrote: > Hello, James! > > I found an error at GetMem / ReAllocMem: Your code: > > getMem(tmpStrings, 100); > {reAllocMem(tmpStrings, (I + 1));} > > reserves 100 or (I + 1) BYTES, but you need space for 100 or (I + 1) > STRINGS, i. e.

Re: [fpc-pascal]Pointer Help

2003-02-09 Thread Anton Tichawa
Hello, James! I found an error at GetMem / ReAllocMem: Your code: getMem(tmpStrings, 100); {reAllocMem(tmpStrings, (I + 1));} reserves 100 or (I + 1) BYTES, but you need space for 100 or (I + 1) STRINGS, i. e. the code should be: getMem(tmpStrings, SizeOf(String) * 100); {reAllocMem(tm

Re: [fpc-pascal]Pointer Help

2003-02-09 Thread James Mills
On Sun, Feb 09, 2003 at 08:30:57PM +1000, James Mills wrote: > Hi all, > > Sorry if this is trivial, but I'm sick of it :) > I'm using fpc to convert my (originally delphi) code to read and write > ini style files, however writing will not work as I want, the data in > the pointer keeps getting fi

[fpc-pascal]Pointer Help

2003-02-09 Thread James Mills
Hi all, Sorry if this is trivial, but I'm sick of it :) I'm using fpc to convert my (originally delphi) code to read and write ini style files, however writing will not work as I want, the data in the pointer keeps getting filled with junk. I'm using getMem, and reAllocMem functions to create dyn