Lazarus

Programming => Operating Systems => Android => Topic started by: roeug on October 22, 2012, 12:55:00 pm

Title: CopyMemory, MoveMemory, ZeroMemory
Post by: roeug on October 22, 2012, 12:55:00 pm
How make CopyMemory, MoveMemory, ZeroMemory available in porting from Win?
Title: Re: CopyMemory, MoveMemory, ZeroMemory
Post by: Leledumbo on October 22, 2012, 01:18:29 pm
Use the respective Pascal (platform independent ones):
Title: Re: CopyMemory, MoveMemory, ZeroMemory
Post by: Laksen on October 22, 2012, 03:20:17 pm
Use the respective Pascal (platform independent ones):
  • CopyMemory -> Move(<source>,<dest>,<size>);
  • MoveMemory -> doesn't really exist, do you really need to?
  • ZeroMemory -> FillByte(<a variable>,<the variable size>,0);
It's the other way around. MoveMemory is the equivalent of the Pascal Move function. CopyMemory has no equivalent and is inherently unsafe, and should be replaced with Move
Title: Re: CopyMemory, MoveMemory, ZeroMemory
Post by: roeug on October 24, 2012, 08:25:32 am
Thanks (Could find myself -  was in hurry)

Another question: File routines?

In windows they were
CreateFile
GetFileSize
CreateFileMapping
MapViewOfFile
UnmapViewOfFile
CloseHandle( THandle from CreateFileMapping)
SetFilePointer
+AccessMode

Where can I find analogs in lazarus ?
 TMemoryStream - ok
Title: Re: CopyMemory, MoveMemory, ZeroMemory
Post by: Leledumbo on October 24, 2012, 02:14:11 pm
Quote
Another question: File routines?
Classic: http://www.freepascal.org/docs-html/rtl/system/filefunctions.html
Modern: http://www.freepascal.org/docs-html/rtl/sysutils/ioroutines.html
OOP: http://www.freepascal.org/docs-html/rtl/classes/tfilestream.html
Title: Re: CopyMemory, MoveMemory, ZeroMemory
Post by: Laksen on October 24, 2012, 03:25:34 pm
File mapping is very platform specific. On windows you have MapViewOfFile, while on a POSIX system you can use mmap.

I don't know if anyone has made a crossplatform unit for that, but it should be possible. Otherwise you can fall back on streams
TinyPortal © 2005-2018