LMemType
typdef enum {
LMEM_TYPE_GENERAL,
LMEM_TYPE_WINDOW,
LMEM_TYPE_OBJ_BLOCK,
LMEM_TYPE_GSTATE,
LMEM_TYPE_FONT_BLK,
LMEM_TYPE_GSTRING,
LMEM_TYPE_DB_ITEMS
} LMemType;
LMem heaps are created for many different purposes. Some of these purposes require the heap to have special functionality. For this reason, when you create an LMem heap, you must specify what it will be used for. The following types are available:
-
LMEM_TYPE_GENERAL
-
The LMem heap will be used for general data storage, possibly including a chunk, name, or element array. When an application creates an LMem heap, it will almost always be of type "General" or "Object."
-
LMEM_TYPE_OBJ_BLOCK
-
Objects are stored in object blocks, which are LMem heaps. An object block has some extra header information and contains one chunk which contains only flags. All the objects in the block are stored as chunks on the heap. Applications can directly create object blocks.
-
LMEM_TYPE_WINDOW
-
Windows are stored in memory as LMem heaps. The header contains information about the window; each region in the window is stored as a chunk. Applications will not directly create Window heaps.
-
LMEM_TYPE_GSTATE
-
A GState is an LMem heap. The GState information is in the header, and the application clip-rectangle is stored in a chunk. Applications do not directly create GState blocks; rather, they call a GState creation routine, which creates the block.
-
LMEM_TYPE_FONT_BLOCK
-
Font blocks are stored as LMem heaps. Applications do not create font blocks directly.
-
LMEM_TYPE_GSTRING
-
Whenever a GString is created or loaded, a GString LMem heap is created, and elements are added as chunks. The heap is created automatically by the GString routines; applications should not create GString blocks.
-
LMEM_TYPE_DB_ITEMS
-
The Virtual Memory mechanism provides routines to create and manage database items, short pieces of data which are dynamically allocated and are saved with the VM file. Applications do not directly allocate DB blocks; rather, they call DB routines, which see to it that the blocks are created.
Include:
lmem.h
LocalMemoryFlags
typedef WordFlags LocalMemoryFlags;
#define LMF_HAS_FLAGS 0x8000
#define LMF_IN_RESOURCE 0x4000
#define LMF_DETACHABLE 0x2000
#define LMF_DUPLICATED 0x1000
#define LMF_RELOCATED 0x0800
#define LMF_AUTO_FREE 0x0400
#define LMF_IN_LMEM_ALLOC 0x0200
#define LMF_IS_VM 0x0100
#define LMF_NO_HANDLES 0x0080
#define LMF_NO_ENLARGE 0x0040
#define LMF_RETURN_ERRORS 0x0020
#define LMF_DEATH_COUNT 0x0007
#define STD_LMEM_OBJECT_FLAGS (LMF_HAS_FLAGS | LMF_RELOCATED)
When an LMem heap is allocated, certain flags are passed to indicate properties the heap should have. Some of the flags are passed only for system-created heaps. The flags are stored in a word-length record (
LocalMemoryFlags
); the record also contains flags indicating the current state of the heap. The
LocalMemoryFlags
are listed below:
-
LMF_HAS_FLAGS
-
Set if the block has a chunk containing only flags. This flag is set for object blocks; it is usually cleared for general LMem heaps.
-
LMF_IN_RESOURCE
-
Set if the block has just been loaded from a resource and has not been changed since being loaded. This flag is set only for object blocks created by the compiler.
-
LMF_DETACHABLE
-
Set if the block is an object block which can be saved to a state file.
-
LMF_DUPLICATED
-
Set if block is an object block created by the
ObjDuplicateResource()
routine. This flag should not be set by applications.
-
LMF_RELOCATED
-
Set if all the objects in the block have been relocated. The object system sets this when it has relocated all the objects in the block.
-
LMF_AUTO_FREE
-
This flag is used by several object routines. It indicates that if the block's in-use count drops to zero, the block may be freed. This flag should not be set by applications.
-
LMF_IN_MEM_ALLOC
-
This flag is used in error-checking code to prevent the heap from being validated while a chunk is being allocated. For internal use only--do not modify
.
-
LMF_IS_VM
-
Set if the LMem heap is in a VM block and the block should be marked dirty whenever a chunk is marked dirty. This flag is automatically set by the VM code when an LMem heap is created in or attached to a VM file. This flag should not be set by applications.
-
LMF_NO_HANDLES
-
Set if block does not use chunk handles. A block can be set to simulate the C
malloc()
routine; in this case, chunks are not relocated after being created, so chunk handles are not needed. Ordinarily, these blocks are created by the
malloc()
routine, not by applications.
-
LMF_NO_ENLARGE
-
Indicates that the local-memory routines should not enlarge this block to fulfill chunk requests. This guarantees that the block will not be moved by a chunk allocation request; however, it makes these requests more likely to fail.
-
LMF_RETURN_ERRORS
-
Set if local memory routines should return errors when allocation requests cannot be fulfilled. If the flag is not set, allocation routines will fatal-error if they cannot comply with requests. This flag is generally clear for expandable LMem blocks, since many system routines (such as
ObjInstantiate()
) are optimized in such a way that they cannot deal with LMem allocation errors.
-
LMF_DEATH_COUNT
-
This field occupies the least significant three bits of the flag field. It means nothing if the value is zero. If it is non-zero, it indicates the number of remove-block messages left which must hit
BlockDeathCommon
before it will free the block. This flag is used by error-checking code in the kernel.
-
STD_LMEM_OBJ_FLAGS
-
This is a constant which combines the LMF_HAS_FLAGS and LMF_RELOCATED flags. These flags should be set for all object blocks.
Include:
lmem.h