Board index » delphi » FPC: ^longint type

FPC: ^longint type

Hi,
in the help of FPC there is mentioned that declaring a variable as
^longint is actually an infinite array of longint.  After calling a getmem
on this variable everything works as supposed.  But now I want to resize
that array, how do I do that (besides from creating a new array and
copying element by element into this new one)?

greetings
Wal

 

Re:FPC: ^longint type


Quote
Walied Othman wrote:

> Hi,
> in the help of FPC there is mentioned that declaring a variable as
> ^longint is actually an infinite array of longint.  After calling a getmem
> on this variable everything works as supposed.  But now I want to resize
> that array, how do I do that (besides from creating a new array and
> copying element by element into this new one)?

When you have a development snapshot, then you can use ReAllocMem().

Re:FPC: ^longint type


In article <388C4166.ACC72...@wins.uva.nl>, pfvre...@wins.uva.nl says...

Quote
> Walied Othman wrote:

> > Hi,
> > in the help of FPC there is mentioned that declaring a variable as
> > ^longint is actually an infinite array of longint.  After calling a getmem
> > on this variable everything works as supposed.  But now I want to resize
> > that array, how do I do that (besides from creating a new array and
> > copying element by element into this new one)?

I had the same problem.
You do need to allocate a new array (buffer) and copy all elements.
However, you can use Move to copy the whole block at once instead of
copying the elements one by one.

Quote
> When you have a development snapshot, then you can use ReAllocMem().

This works in the same way, but is a lot easier :)

Re:FPC: ^longint type


In article <MPG.12f6c1e5503e512e989...@news.casema.net>, SnipeZ

Quote
<kam...@casema.net> wrote:
> > When you have a development snapshot, then you can use ReAllocMem().

> This works in the same way, but is a lot easier :)

It can also be faster in some cases, because the heapmanager tried to
enlarge the current allocated heap block to avoid having to copy the
data. I'm not sure how often it succeeds in doing this though.

Jonas

Other Threads