Recent

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

roeug

  • Jr. Member
  • **
  • Posts: 67
    • 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: 8746
  • 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

  • Hero Member
  • *****
  • Posts: 724
    • 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: 67
    • 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

  • Hero Member
  • *****
  • Posts: 724
    • 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

 

TinyPortal © 2005-2018