AllocateFromAssimpHeap: add overload for nothrow-new.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@666 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
33544456cd
commit
875b7f9ca2
|
@ -45,19 +45,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "AssimpPCH.h"
|
#include "AssimpPCH.h"
|
||||||
|
|
||||||
// .......................................................................................
|
// ------------------------------------------------------------------------------------------------
|
||||||
/* Uncomment this line to prevent Assimp from catching unknown exceptions.
|
/* Uncomment this line to prevent Assimp from catching unknown exceptions.
|
||||||
*
|
*
|
||||||
* Note that any Exception except ImportErrorException may lead to
|
* Note that any Exception except DeadlyImportError may lead to
|
||||||
* undefined behaviour -> loaders could remain in an unusable state and
|
* undefined behaviour -> loaders could remain in an unusable state and
|
||||||
* further imports with the same Importer instance could fail/crash/burn ...
|
* further imports with the same Importer instance could fail/crash/burn ...
|
||||||
*/
|
*/
|
||||||
// .......................................................................................
|
// ------------------------------------------------------------------------------------------------
|
||||||
#define ASSIMP_CATCH_GLOBAL_EXCEPTIONS
|
#define ASSIMP_CATCH_GLOBAL_EXCEPTIONS
|
||||||
|
|
||||||
// .......................................................................................
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Internal headers
|
// Internal headers
|
||||||
// .......................................................................................
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "BaseImporter.h"
|
#include "BaseImporter.h"
|
||||||
#include "BaseProcess.h"
|
#include "BaseProcess.h"
|
||||||
#include "DefaultIOStream.h"
|
#include "DefaultIOStream.h"
|
||||||
|
@ -67,10 +68,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "ScenePreprocessor.h"
|
#include "ScenePreprocessor.h"
|
||||||
#include "MemoryIOWrapper.h"
|
#include "MemoryIOWrapper.h"
|
||||||
|
|
||||||
// .......................................................................................
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Importers
|
// Importers
|
||||||
// (include_new_importers_here)
|
// (include_new_importers_here)
|
||||||
// .......................................................................................
|
// ------------------------------------------------------------------------------------------------
|
||||||
#ifndef AI_BUILD_NO_X_IMPORTER
|
#ifndef AI_BUILD_NO_X_IMPORTER
|
||||||
# include "XFileImporter.h"
|
# include "XFileImporter.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -168,9 +169,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
# include "COBLoader.h"
|
# include "COBLoader.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// .......................................................................................
|
// ------------------------------------------------------------------------------------------------
|
||||||
// PostProcess-Steps
|
// Post processing-Steps
|
||||||
// .......................................................................................
|
// ------------------------------------------------------------------------------------------------
|
||||||
#ifndef AI_BUILD_NO_CALCTANGENTS_PROCESS
|
#ifndef AI_BUILD_NO_CALCTANGENTS_PROCESS
|
||||||
# include "CalcTangentsProcess.h"
|
# include "CalcTangentsProcess.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -241,15 +242,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
using namespace Assimp::Intern;
|
using namespace Assimp::Intern;
|
||||||
|
|
||||||
// .......................................................................................
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Intern::AllocateFromAssimpHeap serves as abstract base class. It overrides
|
// Intern::AllocateFromAssimpHeap serves as abstract base class. It overrides
|
||||||
// new and delete (and their array counterparts) of public API classes (e.g. Logger) to
|
// new and delete (and their array counterparts) of public API classes (e.g. Logger) to
|
||||||
// utilize our DLL heap
|
// utilize our DLL heap.
|
||||||
// .......................................................................................
|
// See http://www.gotw.ca/publications/mill15.htm
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
void* AllocateFromAssimpHeap::operator new ( size_t num_bytes) {
|
void* AllocateFromAssimpHeap::operator new ( size_t num_bytes) {
|
||||||
return ::operator new(num_bytes);
|
return ::operator new(num_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void* AllocateFromAssimpHeap::operator new ( size_t num_bytes, const std::nothrow_t& ) {
|
||||||
|
try {
|
||||||
|
return AllocateFromAssimpHeap::operator new( num_bytes );
|
||||||
|
}
|
||||||
|
catch( ... ) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AllocateFromAssimpHeap::operator delete ( void* data) {
|
void AllocateFromAssimpHeap::operator delete ( void* data) {
|
||||||
return ::operator delete(data);
|
return ::operator delete(data);
|
||||||
}
|
}
|
||||||
|
@ -258,6 +269,15 @@ void* AllocateFromAssimpHeap::operator new[] ( size_t num_bytes) {
|
||||||
return ::operator new[](num_bytes);
|
return ::operator new[](num_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void* AllocateFromAssimpHeap::operator new[] ( size_t num_bytes, const std::nothrow_t& ) {
|
||||||
|
try {
|
||||||
|
return AllocateFromAssimpHeap::operator new[]( num_bytes );
|
||||||
|
}
|
||||||
|
catch( ... ) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AllocateFromAssimpHeap::operator delete[] ( void* data) {
|
void AllocateFromAssimpHeap::operator delete[] ( void* data) {
|
||||||
return ::operator delete[](data);
|
return ::operator delete[](data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,10 +63,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "aiQuaternion.h"
|
#include "aiQuaternion.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
# include <string> // for aiString::Set(const std::string&)
|
#include <new> // for std::nothrow_t
|
||||||
|
#include <string> // for aiString::Set(const std::string&)
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
//! @cond never
|
//! @cond never
|
||||||
namespace Intern {
|
namespace Intern {
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
@ -83,13 +83,16 @@ namespace Intern {
|
||||||
*/
|
*/
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
struct ASSIMP_API AllocateFromAssimpHeap {
|
struct ASSIMP_API AllocateFromAssimpHeap {
|
||||||
|
// http://www.gotw.ca/publications/mill15.htm
|
||||||
|
|
||||||
// new/delete overload
|
// new/delete overload
|
||||||
void *operator new ( size_t num_bytes);
|
void *operator new ( size_t num_bytes) /* throw( std::bad_alloc ) */;
|
||||||
|
void *operator new ( size_t num_bytes, const std::nothrow_t& ) throw();
|
||||||
void operator delete ( void* data);
|
void operator delete ( void* data);
|
||||||
|
|
||||||
// array new/delete overload
|
// array new/delete overload
|
||||||
void *operator new[] ( size_t num_bytes);
|
void *operator new[] ( size_t num_bytes) /* throw( std::bad_alloc ) */;
|
||||||
|
void *operator new[] ( size_t num_bytes, const std::nothrow_t& ) throw();
|
||||||
void operator delete[] ( void* data);
|
void operator delete[] ( void* data);
|
||||||
|
|
||||||
}; // struct AllocateFromAssimpHeap
|
}; // struct AllocateFromAssimpHeap
|
||||||
|
|
Loading…
Reference in New Issue