Page 1 of 1

Memory functions similar to file functions

Posted: Sun Jun 17, 2007 4:25 pm
by localmotion34
Whenever working with memory buffers, i always find myself looking for a better algorithm to determine where i am inside the buffer, especially when decoding image scanlines or reading compressed data. i did notice however, that when working with files, i always know i am at the file position right after where i just read. the file operations keep the position constant until the next operation, or the file is closed.

How about a memory function like ReadMemory(Buffer), which after reading a long/word/byte, keeps the memory position right after where you just read, similar to the file functions.

so:

ReadMemory(buffer)
long=RMreadlong(buffer)
debug memloc(buffer)
word=RMreadword(buffer)
debug memloc(buffer)
MemorySeek(buffer,somewhere)
Debug EOM(buffer) ; "End of Memory"
closememory(buffer)

This would enormously simplify dealing with large memory blocks, and would avoid having to do:

for d=0 to something
long=peekl(buffer, (x*y*d)+ d)
next