Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Copying huge amounts of memory
#1
I have a problem. I need to be able to copy a huge amount of memory over and over again and I need to figure out the fastest way to do it. I am pretty sure that it it using memcpy, but it crashes, what am I doing wrong here?
Code:
#include "crt.bi"
screenres 320, 200, 32,
dim hugeblock2 as integer ptr
dim hugeblock as integer ptr
hugeblock2 = imagecreate(1024, 2048)
hugeblock = imagecreate(1024, 2048)
dim t as double
dim i as integer
t = timer
FOR i = 0 to 50
   memcpy(hugeblock, hugeblock2, 8400900)
NEXT
print timer - t
t = timer
FOR i = 0 to 50
   PUT hugeblock, (0,0), hugeblock2, pset
NEXT
print timer - t
sleep
imagedestroy hugeblock2
imagedestroy hugeblock
f you play a Microsoft CD backwards you can hear demonic voices. The scary part is that if you play it forwards it installs Windows.
Reply
#2
1024(width) * 2048(height) * 4(bytes per pixel) + 4(bytes in FB image header) = 8388612 bytes

So you're copying 12288 too many bytes.
Reply
#3
o man, i kept thinking of the dimentions as 1025x2049, oops.
f you play a Microsoft CD backwards you can hear demonic voices. The scary part is that if you play it forwards it installs Windows.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)