[fpc-pascal] Getmem -> Move -> Freemem

Guillermo Martínez Jiménez gmjimen at burdjia.com
Sun Apr 26 18:32:24 CEST 2009


Hello.

I'm using FPC 2.2.2 on Xubuntu 8.10.

I need to reserve dynamic memory to store raw binary data. I tried the
next code:

  fSize := aObject^.size;
  GetMem (fData, fSize);
  Move (aObject^.dat, fData, fSize);

Both "fData" and "dat" are untyped POINTER but the program returns an
"Segment violation" at the Move procedure. I've checked the pointers
and both are valid (I mean not NIL) and size is always more than zero.

I've read some documentation about the heap memory but I can't
understand why my code doesn't works.

Any idea?

Guillermo "Ñuño" Martínez



More information about the fpc-pascal mailing list