Fix destructor premature call in memstack cpp api

This commit is contained in:
Doyle Thai 2017-06-23 19:05:51 +10:00
parent 9bb8efcf9d
commit 3d61d66388

10
dqn.h
View File

@ -66,7 +66,7 @@
#define DQN_UNIX_PLATFORM #define DQN_UNIX_PLATFORM
#endif #endif
#ifdef __cplusplus #if defined(__cplusplus)
#define DQN_CPP_MODE #define DQN_CPP_MODE
#endif #endif
@ -233,7 +233,7 @@ typedef struct DqnMemStack
void TempRegionEnd (DqnMemStackTempRegion region); void TempRegionEnd (DqnMemStackTempRegion region);
// Scoped Temporary Regions API // Scoped Temporary Regions API
struct DqnMemStackTempRegionScoped TempRegionScoped(bool *const succeeded); struct DqnMemStackTempRegionScoped TempRegionScoped();
// Advanced API // Advanced API
DqnMemStackBlock *AllocateCompatibleBlock(size_t size); DqnMemStackBlock *AllocateCompatibleBlock(size_t size);
@ -1733,8 +1733,10 @@ DqnMemStackTempRegion DqnMemStack::TempRegionBegin()
DQN_ASSERT_HARD(succeeded); DQN_ASSERT_HARD(succeeded);
return result; return result;
} }
void DqnMemStack::TempRegionEnd(DqnMemStackTempRegion region) { DqnMemStackTempRegion_End(region); } void DqnMemStack::TempRegionEnd(DqnMemStackTempRegion region) { DqnMemStackTempRegion_End(region); }
DqnMemStackTempRegionScoped DqnMemStack::TempRegionScoped(bool *const succeeded) { return DqnMemStackTempRegionScoped(this, succeeded); }
// NOTE: Guaranteed to always succeed. Fails when arguments are invalid, like a NULL ptr which is impossible here.
DqnMemStackTempRegionScoped DqnMemStack::TempRegionScoped() { return DqnMemStackTempRegionScoped(this, NULL); }
DqnMemStackBlock *DqnMemStack::AllocateCompatibleBlock(size_t size) { return DqnMemStack_AllocateCompatibleBlock(this, size); } DqnMemStackBlock *DqnMemStack::AllocateCompatibleBlock(size_t size) { return DqnMemStack_AllocateCompatibleBlock(this, size); }
bool DqnMemStack::AttachBlock (DqnMemStackBlock *const newBlock) { return DqnMemStack_AttachBlock (this, newBlock); } bool DqnMemStack::AttachBlock (DqnMemStackBlock *const newBlock) { return DqnMemStack_AttachBlock (this, newBlock); }