EM_findEmptySlot Function (ROM Call 0x15F*)

flash.h

void *EM_findEmptySlot (unsigned long Size);

Finds an empty space in the archive memory of the given size.

EM_findEmptySlot returns a pointer to a place in the archive memory which is large enough to store a block which is Size bytes long. It returns NULL if the requirement cannot be satisfied. In such case, a garbage collection (see EM_GC) is recommended, and there is a chance that a next call of EM_findEmptySlot will be successful. If not, there is really not enough space in the archive memory for a block of the given size. Thanks to Johan Eilert for information how this function should be defined to work on both AMS 1.xx and AMS 2.xx.

Note: The pointer returned by EM_findEmptySlot points to the place where the actual block needs to be stored (see EM_write), not to the place where the header of the block should be stored. The header begins 4 bytes before returned value on AMS 1.xx and 22 bytes before returned value on AMS 2.xx. Note that you need to write a header for each stored block if you don't want problems. See EM_write for more info.


Uses: EM_write, ROM Call 0x3CF, ROM Call 0x3D1
Used by: EM_moveSymToExtMem