OGRE-Next: Ogre::FreeOnDestructor Struct Reference

| OGRE-Next 3.0.0 Object-Oriented Graphics Rendering Engine

Loading...
Searching...
No Matches
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

References ptr.

## ◆ ~FreeOnDestructor()

Ogre::FreeOnDestructor::~FreeOnDestructor | ( |  | ) |
| inline

References Ogre::MEMCATEGORY_GEOMETRY, OGRE_FREE_SIMD, and ptr.

## Member Data Documentation

## ◆ ptr

void* Ogre::FreeOnDestructor::ptr

Referenced by FreeOnDestructor(), and ~FreeOnDestructor().

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

- OgreBufferPacked.h