[Main]
Name=EM_findEmptySlot
Type=Function
Subtype=ROM Call
Header Files=flash.h
Definition=void *EM_findEmptySlot (unsigned long Size);
Real Definition=#define EM_findEmptySlot(s) (__EM_findEmptySlot ((s), 0))

[ROM Call]
Index=$15F

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

[Explanation]
EM_findEmptySlot returns a pointer to a place in the archive memory which is large enough
to store a block which is <I>Size</I> bytes long. It returns <A HREF="$$LINK(alloc.h/NULL)">NULL</A> if
the requirement cannot be satisfied. In such case, a garbage collection (see
<A HREF="$$LINK(flash.h/EM_GC)">EM_GC</A>) 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.
<BR><BR>
<B>Note:</B> The pointer returned by EM_findEmptySlot points to the place where the actual block
needs to be stored (see <A HREF="$$LINK(flash.h/EM_write)">EM_write</A>), 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 <A HREF="$$LINK(flash.h/EM_write)">EM_write</A> for more info.

[References]
Out=flash.h/EM_write, flash.h/EM_getArchiveMemoryBeginning, unknown.h/_ROM_CALL_3D1
In=vat.h/EM_moveSymToExtMem
