API Reference | developer.brewmp.com API Reference | developer.brewmp.com


API Reference


Brew Release
Brew MP 1.0.2
See Also
Helper Functions

WARNING: This function should not be used without clearly understanding all rules associated with handled-based memory.
By default, all memory allocated via the BREW heap is locked and cannot be relocated. This function provides a means for the caller to specify that a recently allocated memory block can be moved. It is called as follows:
Note that the following 2 dangerous conditions must be avoided:
- Passing a handle to memory that resides inside a moveable memory block.
- Assigning a handle to memory when that memory is already referenced
by a handle in another block.
Initial Allocation:
pme->m_ptr = MALLOC(100); UNLOCKMEM(&pme->m_ptr); // Make memory free to move.
LOCKMEM(&pme->m_ptr); Perform Work... UNLOCKMEM(&pme->m_ptr);

As indicated, this function accepts a pointer to a handle of allocated memory. The function will then mark the block as available to be moved in memory. Note that this function monitors a "lock count" on the memory block. This allows the caller to pair LOCKMEM and UNLOCKMEM inside sub-routines that may be called while the memory is locked. In such cases, the memory will not actually be "unlocked" until the reference count reaches 0.
  •    int UNLOCKMEM(void ** ppHandle);
  • The return value is indeterminate and should be ignored.
Side Effect
  • None