summaryrefslogtreecommitdiff
path: root/deps/g3dlite/include/G3D/debug.h
blob: 4f34e5b3b6238fd601e62afb6dfc263212e82aac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/**
 \file debug.h

 \maintainer Morgan McGuire, http://graphics.cs.williams.edu

 \created 2001-08-26
 \edited  2008-08-16

 Copyright 2000-2006, Morgan McGuire.
 All rights reserved.
*/

#ifndef G3D_debug_h
#define G3D_debug_h

#include "G3D/platform.h"
#ifdef _MSC_VER
    #include <crtdbg.h>
#endif

#include "G3D/debugPrintf.h"
#include "G3D/debugAssert.h"

namespace G3D {

#ifdef _MSC_VER
    // Turn off 64-bit warnings
#   pragma warning(push)
#   pragma warning( disable : 4312)
#   pragma warning( disable : 4267)
#   pragma warning( disable : 4311)
#endif


/**
 Useful for debugging purposes.
 */
inline bool isValidHeapPointer(const void* x) {
    #ifdef _MSC_VER
        return 
            (x != NULL) &&
            (x != (void*)0xcccccccc) && (x != (void*)0xdeadbeef) && (x != (void*)0xfeeefeee) &&
            (x != (void*)0xcdcdcdcd) && (x != (void*)0xabababab) && (x != (void*)0xfdfdfdfd);
    #else
        return x != NULL;
    #endif
}

/**
 Returns true if the pointer is likely to be
 a valid pointer (instead of an arbitrary number). 
 Useful for debugging purposes.
 */
inline bool isValidPointer(const void* x) {
    #ifdef _MSC_VER
        return (x != NULL) &&
            (x != (void*)0xcccccccc) && (x != (void*)0xdeadbeef) && (x != (void*)0xfeeefeee) &&
            (x != (void*)0xcdcdcdcd) && (x != (void*)0xabababab) && (x != (void*)0xfdfdfdfd);
    #else
        return x != NULL;
    #endif
}

#ifdef _MSC_VER
#   pragma warning(pop)
#endif

}

#endif