* * *

Author Topic: CopyMemory, MoveMemory, ZeroMemory  (Read 2887 times)

roeug

  • Jr. Member
  • **
  • Posts: 62
    • http://roeug.50megs.com/
CopyMemory, MoveMemory, ZeroMemory
« on: October 22, 2012, 12:55:00 pm »
How make CopyMemory, MoveMemory, ZeroMemory available in porting from Win?

Leledumbo

  • Hero Member
  • *****
  • Posts: 5473
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: CopyMemory, MoveMemory, ZeroMemory
« Reply #1 on: October 22, 2012, 01:18:29 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);

Laksen

  • Sr. Member
  • ****
  • Posts: 449
    • J-Software
Re: CopyMemory, MoveMemory, ZeroMemory
« Reply #2 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

roeug

  • Jr. Member
  • **
  • Posts: 62
    • http://roeug.50megs.com/
Re: CopyMemory, MoveMemory, ZeroMemory
« Reply #3 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
« Last Edit: October 24, 2012, 11:40:51 am by roeug »


Laksen

  • Sr. Member
  • ****
  • Posts: 449
    • J-Software
Re: CopyMemory, MoveMemory, ZeroMemory
« Reply #5 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

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads