[fpc-pascal]Pointer Help
James Mills
prologic at prologitech.com
Sun Feb 9 12:45:00 CET 2003
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. the code should be:
>
> getMem(tmpStrings, SizeOf(String) * 100);
> {reAllocMem(tmpStrings, SizeOf(String) * (I + 1));}
>
> Even then, I don't know if fpc behaves correctly converning deallocation when
> <String> defaults to <AnsiString>. Maybe somebody else can respond to this?
>
> Another note: Please replace tabulators by spaces when posting code.
>
> Hope this Helps.
>
> Anton Tichawa.
Thank you, I"ll try that.
>
>
>
> On Sunday 09 February 2003 11:30, you 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 filled with junk.
> >
> > I'm using getMem, and reAllocMem functions to create dynamic arrays of
> > strings. The writeINI function reads the entire file in, but doesn't
> > even do that correctly.
> >
> > I have a test program that uses the same idea, and it works perfectly,
> > so I'm very bewildered :(
> >
> > attached is the code if someone would like to have a look at it, please.
> >
> > thank you
> > James
>
>
>
> ----------
>
> "Adas Methode war, wie sich zeigen wird, Tagtr?ume in offenbar korrekte
> Berechnungen einzuweben."
>
> Doris Langley Moore: Ada, Countess of Lovelace (London 1977).
>
> ----------
>
> Anton Tichawa
> Volkertstrasse 19 / 20
> A-1020 Wien
> mobil: +43 664 52 07 907
> email: anton.tichawa at chello.at
>
> ----------
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
More information about the fpc-pascal
mailing list