Developer

API Reference

IMenuModel_SetPfnFree()

Brew Release
Brew MP 1.0.2
See Also
- IMenuModel Interface
- PFNMODEL_NOTIFY
Description
This function specifies the callback function to be used by the menu model when releasing memory occupied by the items it stores. The menu model manages information about each menu item, including its attribute flags, command ID and a content pointer to the data an attached object would use to render the menu item on the user interface. The data referenced by the content pointer is opaque to the menu model and could point to an arbitrarily complex data structure with its own unique storage requirements. The callback function allows a menu model to release "deep storage" -- custom memory allocated by an application and stored in the fields of an application defined data structure that is otherwise opaque to the menu model itself.
The figure below illustrates complex items in a menu model that possesses "deep storage". Each item stored in the menu model references content data allocated and owned by the application. For item x, this content storage includes a pointer to additional storage allocated and used by item x (the menu model doesn't even know this storage exists). To release this storage, the menu model would provide a PFNMODEL_NOTIFY callback that would free the contents of item x, as well as the custom memory pointed to from within item x.
                                                      +--------------------------+
                                                      |                          |
                                :                     |        Contents of       |
                                :                     |           item x         |
                   |--------------------------|       |                          |       +---------+
       Item x      |                          |       |    Pointer to custom +---------> |         |
                   |   Content (void *)   +---------> |          storage         |       |         |
                   |                          |       +--------------------------+       +---------+
                   |--------------------------|
                   |                          |
     Item (x + 1)  |   Content (void *)   +---------> +--------------------------+
                   |                          |       |                          |
                   |--------------------------|       |        Contents of       |
                                :                     |        item (x + 1)      |
                                :                     |                          |
                                                      |                          |
                                                      +--------------------------+
Parameters
  • pif
    []:
    Pointer to the IMenuModel interface object.
  • pfn
    []:
    Pointer to the callback function that BREW will call when freeing the memory associated with an item stored in the menu model.
Interface
Prototype
   PFNMODEL_NOTIFY IMenuModel_SetPfnFree(IMenuModel *pif, PFNMODEL_NOTIFY pfn);
Return
IMenuModel_SetPfnFree() returns a pointer to the menu model's old PFNMODEL_NOTIFY callback function.
Side Effect
None
Comment
None
  • Follow