OGRE-Next  2.3
Object-Oriented Graphics Rendering Engine
Ogre::FreeOnDestructor Struct Reference

Helper class to that will free the pointer on the destructor. More...

#include <OgreBufferPacked.h>

Public Member Functions

 FreeOnDestructor (void *_ptr)
 
 ~FreeOnDestructor ()
 

Public Attributes

void * ptr
 

Detailed Description

Helper class to that will free the pointer on the destructor.

Usage: FreeOnDestructor dataPtrContainer( data ); vaoManager->createVertexBuffer( vertexElements, vertexCount, mVertexBufferDefaultType, data, keepAsShadow );

if( !keepAsShadow ) dataPtrContainer.ptr = 0;

In this example, "data" wouln't normally be freed if createVertexBuffer raises an exception according to BufferPacked's constructor rules, but thanks to FreeOnDestructor, the pointer will be freed accordingly. Once the BufferPacked has been created, we need to zero the ptr member to avoid freeing it (since BufferPacked will do it).

Constructor & Destructor Documentation

◆ FreeOnDestructor()

Ogre::FreeOnDestructor::FreeOnDestructor ( void *  _ptr)
inline

◆ ~FreeOnDestructor()

Ogre::FreeOnDestructor::~FreeOnDestructor ( )
inline

Member Data Documentation

◆ ptr

void* Ogre::FreeOnDestructor::ptr

Referenced by ~FreeOnDestructor().


The documentation for this struct was generated from the following file: