Such a persistent store is represented by a PalmOS resource database of the type 'appl'. This type tag causes the application manager to display the store like any other application installed on the Palm. Figure 1 illustrates the basic structural components of a store:
Figure 2 shows the definition of the associated C structure. The field externalManager will be explained in more detail in 3.4.
Each record has its own header block containing status information for the segment. Figure 3 shows the definition of the C structure that contains the header data.
The segmented heap is represented by a linked list of records using the next pointer to locate the following one.
The VM requires all heap objects to be located at a 32-bit aligned address, whereas the operating system may return addresses that are only 16-bit aligned. This problem is solved by actually requesting 16 bits more than needed to hold the record, which leads to one of the following situations.
If the memory area returned by the OS is not 32-bit aligned, the record is ``bumped'' up to the next 32-bit aligned address. When an application is suspended, the fact that the record was bumped is indicated by setting its header's bumped field to TRUE and the two bytes before the record to 0xFFFF (Figure 4). This will be recognized by the VM when it resumes the application, and then it can properly align the contents of the record as described further in section 3.2.
If the memory area returned by the OS is 32-bit aligned, the record is simply placed at the beginning of that memory area leaving 16 bits at the end of it unused.