NAME

OTC_MallocReaper - Destroys data allocated using malloc.

SYNOPSIS


#include <OTC/memory/mcreaper.hh>

class OTC_MallocReaper
{
  public:
    inline OTC_MallocReaper();
    inline ~OTC_MallocReaper();
    inline void grab(void* theData);
    inline void release();
};

CLASS TYPE

Concrete

DESCRIPTION

The class OTC_MallocReaper assists in ensuring that data allocated from the free store using malloc() is deleted when the stack is unwound as a result of an exception. This is achieved by using an instance of this class as a handle to the data allocated using malloc(). Once the data is grabbed using an instance of this class, the section of code in which an exception could be raised is executed. If an exception does occur then the instance of this class will be destroyed and the data freed. If no exception occurs a call can be made to release the data, when the destructor is finally called the data would not be freed.

EXAMPLE

INITIALISATION

inline OTC_MallocReaper();

DESTRUCTION

inline ~OTC_MallocReaper();

GRAB/RELEASE

inline void grab(void* theData);
inline void release();

SEE ALSO

OTC_Reaper, OTC_VecReaper

LIBRARY

OTC

AUTHOR(S)

Graham Dumpleton

COPYRIGHT

Copyright 1993 TELSTRA CORPORATION LIMITED