HDK
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
UT_NoMemHandler.h
Go to the documentation of this file.
1
/*
2
* PROPRIETARY INFORMATION. This software is proprietary to
3
* Side Effects Software Inc., and is not to be reproduced,
4
* transmitted, or disclosed in any way without written permission.
5
*
6
* NAME: UT_NoMemHandler.h ( UT Library, C++)
7
*
8
* COMMENTS:
9
*
10
* This class handles memory allocation failures. Currently only
11
* implemented for Windows and Linux.
12
*
13
*/
14
#ifndef __UT_NoMemHandler_h__
15
#define __UT_NoMemHandler_h__
16
17
#include "
UT_API.h
"
18
#include "
UT_NonCopyable.h
"
19
#include <stdlib.h>
20
21
// A UT_NoMemHandlerCallback is a callback that the application can register
22
// if it wants to be notified when memory allocation has failed.
23
typedef
void
(*
UT_NoMemHandlerCallback
)();
24
25
// The maximum number of callbacks we allow. We do not need a dynamic
26
// array for these since they should all be registered at code startup.
27
#define UT_MEMHANDLER_MAX_CALLBACKS 16
28
29
class
UT_API
UT_NoMemHandler
30
{
31
public
:
32
// Global static accessor to UT_NoMemHandler singleton.
33
static
UT_NoMemHandler
&getNoMemHandler();
34
35
// Call this method to add a memory handler callback. When memory
36
// allocation fails, these callbacks are called. Their current purpose is
37
// to try to free some memory so that we can save before the inevitable
38
// crash.
39
void
addCallback(
UT_NoMemHandlerCallback
callback);
40
41
// The main new handlers called by the C-runtime library.
42
int
classNewHandler(
size_t
size
);
43
44
// Disable handler entirely. Used for non-GUI apps like Houdini Engine.
45
void
disableHandler();
46
47
private
:
48
// Private constructor/destructor because no one is allowed to allocate us.
49
UT_NoMemHandler
();
50
~
UT_NoMemHandler
();
51
UT_NON_COPYABLE
(
UT_NoMemHandler
)
52
53
// The registered callbacks
54
UT_NoMemHandlerCallback
myCallbacks[
UT_MEMHANDLER_MAX_CALLBACKS
];
55
int
myNumCallbacks;
56
57
// This flag is used to avoid recursive calls into our handler in case
58
// one of the callbacks called from it causes another malloc/new to fail.
59
bool
myInsideHandler;
60
61
// Once disabled, this handler will never allow new callbacks to be added.
62
bool
myHandlerDisabled;
63
};
64
65
#endif
void
void
Definition:
png.h:1083
UT_API.h
UT_API
#define UT_API
Definition:
UT_API.h:14
UT_NoMemHandler
Definition:
UT_NoMemHandler.h:29
UT_NON_COPYABLE
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
Definition:
UT_NonCopyable.h:31
UT_NonCopyable.h
UT_NoMemHandlerCallback
void(* UT_NoMemHandlerCallback)()
Definition:
UT_NoMemHandler.h:23
size
GLsizeiptr size
Definition:
glcorearb.h:664
UT_MEMHANDLER_MAX_CALLBACKS
#define UT_MEMHANDLER_MAX_CALLBACKS
Definition:
UT_NoMemHandler.h:27
UT
UT_NoMemHandler.h
Generated on Sun Nov 17 2024 03:03:47 for HDK by
1.8.6