Developer

API Reference

IVectorModel_SetPfnFree()

Brew Release
Brew MP 1.0.2
See Also
IVectorModel Interface PFNMODEL_NOTIFY
Description
This function specifies the callback function to be used by the vector model when releasing memory occupied by items stored in the vector model. The vector model maintains an array of pointers to the contents of each item, with the items defining their individual structure and storage requirements. The callback function allows a vector model to release "deep storage" -- custom memory allocated and occupied by the fields of the items stored in a vector model.
The figure below illustrates complex items in a vector model that possess "deep storage". A pointer to the contents of item x is stored in the vector model's array of item pointers. The item itself then includes a pointer to additional storage allocated and used by item x. To release this storage, the vector 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 +---------> |         |
                   |          void *      +---------> |          storage         |       |         |
                   |                          |       +--------------------------+       +---------+
                   |--------------------------|
                   |                          |
     Item (x + 1)  |          void *      +---------> +--------------------------+
                   |                          |       |                          |
                   |--------------------------|       |        Contents of       |
                                :                     |        item (x + 1)      |
                                :                     |                          |
                                                      |                          |
                                                      +--------------------------+
Parameters
  • po
    []:
    Pointer to the IVectorModel interface object.
  • pfnFree
    []:
    Pointer to the callback function that BREW will call when freeing the memory associated with an item stored in the vector model.
Interface
Prototype
   PFNMODEL_NOTIFY IVectorModel_SetPfnFree(IVectorModel *po, PFNMODEL_NOTIFY pfnFree);
Return
IVectorModel_SetPfnFree() returns a pointer to the vector model's old PFNMODEL_NOTIFY callback function. A vector model may therefore manage multiple PFNMODEL_NOTIFY callbacks, each capable of managing different item contents.
Side Effect
None
Comment
Pass VF_RELEASE in 'pfnFree' to indicate that the item pointers stored in the vector model are actually interface pointers. When this is the case, the vector model will release the interfaces by calling IBASE_Release().
  • Follow