forked from stepcode/stepcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscl_memmgr.h
More file actions
80 lines (58 loc) · 2.3 KB
/
scl_memmgr.h
File metadata and controls
80 lines (58 loc) · 2.3 KB
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
71
72
73
74
75
76
77
78
79
80
#ifndef SCL_MEMMGR_H
#define SCL_MEMMGR_H
#include <scl_export.h>
/**
Platform specific defines
*/
#if defined(__MSVC__) || defined(__BORLAND__)
#define THROW_STD_BAD_ALLOC
#define THROW_EMPTY
#else
#define THROW_STD_BAD_ALLOC throw (std::bad_alloc)
#define THROW_EMPTY throw ()
#endif
#ifdef __cplusplus
#include <cstddef>
extern "C" {
#endif /* __cplusplus */
SCL_BASE_EXPORT void * scl_malloc_fn( unsigned int size, const char *file, const int line );
SCL_BASE_EXPORT void * scl_calloc_fn( unsigned int count, unsigned int size, const char *file, const int line );
SCL_BASE_EXPORT void * scl_realloc_fn( void * addr, unsigned int size, const char *file, const int line );
SCL_BASE_EXPORT void scl_free_fn( void * addr );
#ifdef __cplusplus
}
#endif /* __cplusplus */
#ifdef __cplusplus
SCL_BASE_EXPORT void * scl_operator_new( size_t size, const char * file, const int line );
SCL_BASE_EXPORT void scl_operator_delete( void * addr, const char *file, const int line );
SCL_BASE_EXPORT void scl_operator_delete( void * addr );
#endif /* __cplusplus */
#ifndef SCL_MEMMGR_CC
#define scl_malloc(size) scl_malloc_fn(size, __FILE__, __LINE__)
#define scl_calloc(count, size) scl_calloc_fn(count, size, __FILE__, __LINE__)
#define scl_realloc(addr, size) scl_realloc_fn(addr, size, __FILE__, __LINE__)
#define scl_free(addr) scl_free_fn(addr)
#ifdef __cplusplus
#include <new>
inline void * operator new( size_t size, const char *file, const int line ) THROW_STD_BAD_ALLOC {
return scl_operator_new(size, file, line);
}
inline void * operator new[]( size_t size, const char *file, const int line ) THROW_STD_BAD_ALLOC {
return scl_operator_new(size, file, line);
}
inline void operator delete( void *addr, const char *file, const int line ) THROW_STD_BAD_ALLOC {
scl_operator_delete(addr, file, line);
}
inline void operator delete[]( void *addr, const char *file, const int line ) THROW_STD_BAD_ALLOC {
scl_operator_delete(addr, file, line);
}
inline void operator delete( void * addr ) THROW_EMPTY {
scl_operator_delete(addr);
}
inline void operator delete[]( void * addr ) THROW_EMPTY {
scl_operator_delete(addr);
}
#define new new(__FILE__, __LINE__)
#endif /* __cplusplus */
#endif /* SCL_MEMMGR_CC */
#endif /* SCL_MEMMGR_H */