[fpc-pascal] PChar resize

Mattias Gaertner nc-gaertnma at netcologne.de
Wed May 11 16:00:57 CEST 2011


On Wed, 11 May 2011 08:31:02 -0500
Luis Fernando Del Aguila Mejía <luis3000 at ec-red.com> wrote:

> 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



More information about the fpc-pascal mailing list