Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-05

PChar resize

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luis Fernando Del Aguila Mejía

Hi, I have two questions about PChar.

Why Reallocmem function does not work with PChar?
How to increase the size of PChar without using Strings unit?

Thanks.

{$codepage utf8}
Var a:Pchar;
    i:byte;
Begin
ReturnNilIfGrowHeapFails:=true;
a:='xxxxxxxxx';
for i:=0 to 9 do Writeln('[',i,']',a[i]);
Writeln('-------');
Reallocmem(a,20);  //ko
End.

Reply by email

Mattias Gaertner
to Luis Fernando Del Aguila Mejía
Show quoted text 16 lines
Hi, I have two questions about PChar. Why Reallocmem function does not work with PChar? How to increase the size of PChar without using Strings unit? Thanks. {$codepage utf8} Var a:Pchar; i:byte; Begin ReturnNilIfGrowHeapFails:=true; a:='xxxxxxxxx'; for i:=0 to 9 do Writeln('[',i,']',a[i]); Writeln('-------'); Reallocmem(a,20); //ko

Reallocate re-allocates memory on the heap.
A string constant is not on the heap.

Mattias

Reply by email