Move Data in A Bank

BlitzMax Forums/BlitzMax Programming/Move Data in A Bank

Hi,

I'm performing a lot of modifications on data stored in a bank and I need to move one block of data from the middle part of the bank to the end. I'm doing this at the moment by making another temporary bank, copying the data to move into it, then copying that back to the end of the original bank. It works fine, it's just it is extremely slow when performing it on large files as most systems need to page(file) the additional memory.

Is there a way I could use MemMove() to quickly move data from one part of a bank to another?

Thanks

Seb

Have you tried using CopyBank with the same bank for source and destination.

Hmm, looking at the source it calls MemCopy instead of MemMove which is incorrect as overlapping source and destination regions may be involved so yes calling MemMove yourself is pbly your best bet.

I've tried using CopyBank but the data seems to get corrupted (I think because it overlaps). I'll have a play around with MemMove to see if I have any joy. - Will post if I get anywhere with it.

Hi,

I've managed to move data within a bank using MemMove. I've made an addition to the Module Tweaks if anyone wants to use it.

Seb

-------

In BlitzMax\mod\brl.mod\bank.mod\bank.bmx:
Rem
bbdoc: Move data within a bank
about:
#MoveBank moves @count bytes from @offset to @dst_offset.
End Rem
Function MoveBank( bank:TBank,offset,dst_offset,count )
	Assert..
	count>=0 And..
	offset>=0 And..
	offset>=0 And..
	offset+count<=bank.Size() And..
	dst_offset+count<=bank.Size() Else "Illegal range for MoveBank"
	MemMove( bank.Buf()+dst_offset,bank.Buf()+offset,count )
End Function
Then just recompile all the modules.