[fpc-pascal]About ansistrings.

Udo Giacomozzi ugcm at usa.net
Sun Dec 31 17:21:40 CET 2000


Hello FPC,

Sunday, December 31, 2000, 12:40:07 AM, you wrote:


FMlr> Hi. I'm doing some stuff in which i declare a record-type which
FMlr> contains an ansistring. When i try to allocate a variable of that type, i
FMlr> get a General Protection Fault. Here's the source code :

FMlr> Under Go32 it seems to work, but it crashes under Win32 & Linux.

FMlr> I've noticed that if i replace "new(stuff[idx])" with "new(stuff[1])" it
FMlr> works. And Delphi doesn't seem to have any problem with any of the 2 calls
FMlr> to new().

Does this particular code generate the GPF or do you have some other
code after new() ?
as ansistrings are some sort of pointers, sometimes it makes problems
when the variable is not correctly initialized.
i don't know right now if new() clears the contents of the memory
block (ie. sets to zero) but if it don't and you access the string,
you may run into problems.

sometimes it also does not generate an GPF but later in the program
strange things are happening...

Udo

-- 
Best regards,
 Udo                            mailto:ugcm at usa.net






More information about the fpc-pascal mailing list