Up: GEOS SDK TechDocs | Up | Prev: MemAlloc() ... | Next: MemLock() ...

MemDowngradeExclLock()

void	MemDowngradeExclLock(
        MemHandle		mh);			/* handle of affected block */

An application that has an exclusive lock on a block may downgrade it to a shared lock with this routine. It does not otherwise affect the block.

Include: heap.h

MemFree()

void	MemFree(
        MemHandle		mh);			/* handle of block to be freed */

This routine frees a global memory block. The block can be locked or unlocked.

Include: heap.h

Warnings: The routine does not care whether other threads have locked the block. If you try to free a bad handle, routine may fatal-error.

MemGetInfo()

word	MemGetInfo( /* return value depends on flag passed */
        MemHandle		mh, 			/* Handle of block to get info about */
        MemGetInfoType		info);			/* Type of information to get */

MemGetInfo() is a general-purpose routine for getting information about a global memory block. It gets the information by looking in the block's handle table entry; it does not need to access the actual block. It returns a single word of data; the meaning of that word depends on the value of the MemGetInfoType variable passed. The following types are available:

MGIT_SIZE
Return value is size of the block in bytes. This may be larger than the size originally requested, as blocks are allocated along paragraph boundaries.
MGIT_FLAGS_AND_LOCK_COUNT
The upper byte of the return value is the current HeapFlags record for the block. The lower byte is the number of locks currently on the block.
MGIT_OWNER_OR_VM_FILE_HANDLE
If the block is part of a VM file, return value is the VM file handle. Otherwise, return value is the GeodeHandle of the owning thread.
MGIT_ADDRESS
Return value is block's segment address on the global heap, or zero if block has been discarded. If block is unlocked and moveable, address may change without warning. Ordinarily, MemDeref() is preferable.
MGIT_OTHER_INFO
Returns the value of the HM_otherInfo word. This word is used in different ways for different types of handles.
MGIT_EXEC_THREAD
Returns the ThreadHandle of the thread executing this block, if any.

Include: heap.h

Warnings: If the handle is not a global memory block handle, results are unpredictable (the routine will read inappropriate data from the handle table entry).

See Also: MemDeref(), MemModifyFlags(), MemModifyOtherInfo(), HandleModifyOwner().

MemIncRefCount()

void	MemIncRefCount(
        MemHandle		mh);			/* handle of affected block */

This routine increments the reference count of a global memory block (the reference count is stored in HM _otherInfo ).

Warnings: This routine assumes that a reference count is stored in HM _otherInfo . You may only use this routine if the block has had a reference count set up with MemInitRefCount() .

Include: heap.h

MemInitRefCount()

void	MemInitRefCount(
        MemHandle		mh,				/* handle of affected block */
        word		count);				/* initial reference count */

This routine sets up a reference count for the specified global memory block. The passed count is stored in the HM _otherInfo field of the block's handle-table entry.

Warnings: This routine overwrites the HM _otherInfo field. Since the semaphore routines ( HandleP() and HandleV() and the routines which use them) use this field, you cannot use both the semaphore routines and the reference count routines on the same block.

Include: heap.h


Up: GEOS SDK TechDocs | Up | Prev: MemAlloc() ... | Next: MemLock() ...