[fpc-pascal] Function to create a record ? <solved>

Steve Litt slitt at troubleshooters.com
Sun Jun 4 15:37:09 CEST 2023

Henry Vermaak via fpc-pascal said on Fri, 2 Jun 2023 09:38:17 +0100

>On Fri, 2 Jun 2023 at 01:36, Steve Litt via fpc-pascal
><fpc-pascal at lists.freepascal.org> wrote:
>>         fillchar(junkvar, junkvar_size, 'b');
>>         person := modperson(person, 'Martin');
>>         person := modperson(person2, 'Maria');  
>Maybe a typo? (E.g. person2 := modperson(person2, 'Maria'))

Thanks Henry!

You're right: Changing the second person := to person2 := did just what
I wanted it to do.

Because returning a local array or string as a function return in C
leads to horrible intermittents due to the local going out of scope and
relinquishing the local's stack, which can then be overwritten, I added
a procedure, a function, and a main program statement which each
consumed two million bytes of local variables, and the person and
person2 didn't get overwritten. Very cool.

When I increased the huge local vars to three million bytes, the
program segfaulted. I figure I just ran it out of stack, but until I
did, the huge local vars didn't trash the contents of person and

Thanks for your help.


Steve Litt 
Autumn 2022 featured book: Thriving in Tough Times

More information about the fpc-pascal mailing list