mirror of
https://github.com/lubosz/overte.git
synced 2025-04-19 12:24:01 +02:00
added DEADBEEF support to debug class
This commit is contained in:
parent
188d52c06e
commit
2cb46c3447
3 changed files with 27 additions and 0 deletions
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include <NodeList.h>
|
||||
#include <PerfStat.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "AABox.h"
|
||||
#include "OctalCode.h"
|
||||
|
@ -29,6 +30,9 @@ uint64_t OctreeElement::_voxelNodeCount = 0;
|
|||
uint64_t OctreeElement::_voxelNodeLeafCount = 0;
|
||||
|
||||
OctreeElement::OctreeElement() {
|
||||
// Note: you must call init() from your subclass, otherwise the OctreeElement will not be properly
|
||||
// initialized. You will see DEADBEEF in your memory debugger if you have not properly called init()
|
||||
debug::setDeadBeef(this, sizeof(*this));
|
||||
}
|
||||
|
||||
void OctreeElement::init(unsigned char * octalCode) {
|
||||
|
|
|
@ -688,3 +688,21 @@ int unpackFloatFromByte(unsigned char* buffer, float& value, float scaleBy) {
|
|||
return sizeof(holder);
|
||||
}
|
||||
|
||||
char debug::DEADBEEF[] = { 0xDE, 0xAD, 0xBE, 0xEF };
|
||||
int debug::DEADBEEF_SIZE = sizeof(DEADBEEF);
|
||||
void debug::setDeadBeef(void* memoryVoid, int size) {
|
||||
unsigned char* memoryAt = (unsigned char*)memoryVoid;
|
||||
int deadBeefSet = 0;
|
||||
int chunks = size / DEADBEEF_SIZE;
|
||||
for (int i = 0; i < chunks; i++) {
|
||||
memcpy(memoryAt + (i * DEADBEEF_SIZE), DEADBEEF, DEADBEEF_SIZE);
|
||||
deadBeefSet += DEADBEEF_SIZE;
|
||||
}
|
||||
memcpy(memoryAt + deadBeefSet, DEADBEEF, size - deadBeefSet);
|
||||
}
|
||||
|
||||
void debug::checkDeadBeef(void* memoryVoid, int size) {
|
||||
unsigned char* memoryAt = (unsigned char*)memoryVoid;
|
||||
assert(memcmp(memoryAt, DEADBEEF, std::min(size, DEADBEEF_SIZE)) != 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -118,6 +118,11 @@ int removeFromSortedArrays(void* value, void** valueArray, float* keyArray, int*
|
|||
class debug {
|
||||
public:
|
||||
static const char* valueOf(bool checkValue) { return checkValue ? "yes" : "no"; }
|
||||
static void setDeadBeef(void* memoryVoid, int size);
|
||||
static void checkDeadBeef(void* memoryVoid, int size);
|
||||
private:
|
||||
static char DEADBEEF[];
|
||||
static int DEADBEEF_SIZE;
|
||||
};
|
||||
|
||||
bool isBetween(int64_t value, int64_t max, int64_t min);
|
||||
|
|
Loading…
Reference in a new issue