diff options
Diffstat (limited to '')
-rw-r--r-- | CPP/Common/NewHandler.h | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/CPP/Common/NewHandler.h b/CPP/Common/NewHandler.h index aedeca6..50f6d0a 100644 --- a/CPP/Common/NewHandler.h +++ b/CPP/Common/NewHandler.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // Common/NewHandler.h | 1 | // Common/NewHandler.h |
2 | 2 | ||
3 | #ifndef __COMMON_NEW_HANDLER_H | 3 | #ifndef ZIP7_INC_COMMON_NEW_HANDLER_H |
4 | #define __COMMON_NEW_HANDLER_H | 4 | #define ZIP7_INC_COMMON_NEW_HANDLER_H |
5 | 5 | ||
6 | /* | 6 | /* |
7 | NewHandler.h and NewHandler.cpp allows to solve problem with compilers that | 7 | NewHandler.h and NewHandler.cpp allows to solve problem with compilers that |
@@ -10,6 +10,16 @@ don't throw exception in operator new(). | |||
10 | This file must be included before any code that uses operators new() or delete() | 10 | This file must be included before any code that uses operators new() or delete() |
11 | and you must compile and link "NewHandler.cpp", if you use some old MSVC compiler. | 11 | and you must compile and link "NewHandler.cpp", if you use some old MSVC compiler. |
12 | 12 | ||
13 | DOCs: | ||
14 | Since ISO C++98, operator new throws std::bad_alloc when memory allocation fails. | ||
15 | MSVC 6.0 returned a null pointer on an allocation failure. | ||
16 | Beginning in VS2002, operator new conforms to the standard and throws on failure. | ||
17 | |||
18 | By default, the compiler also generates defensive null checks to prevent | ||
19 | these older-style allocators from causing an immediate crash on failure. | ||
20 | The /Zc:throwingNew option tells the compiler to leave out these null checks, | ||
21 | on the assumption that all linked memory allocators conform to the standard. | ||
22 | |||
13 | The operator new() in some MSVC versions doesn't throw exception std::bad_alloc. | 23 | The operator new() in some MSVC versions doesn't throw exception std::bad_alloc. |
14 | MSVC 6.0 (_MSC_VER == 1200) doesn't throw exception. | 24 | MSVC 6.0 (_MSC_VER == 1200) doesn't throw exception. |
15 | The code produced by some another MSVC compilers also can be linked | 25 | The code produced by some another MSVC compilers also can be linked |
@@ -36,13 +46,13 @@ void my_delete(void *p) throw(); | |||
36 | #endif | 46 | #endif |
37 | 47 | ||
38 | 48 | ||
39 | #if defined(_MSC_VER) && (_MSC_VER < 1900) | 49 | #if defined(_MSC_VER) && (_MSC_VER < 1600) |
40 | // If you want to use default operator new(), you can disable the following line | 50 | // If you want to use default operator new(), you can disable the following line |
41 | #define _7ZIP_REDEFINE_OPERATOR_NEW | 51 | #define Z7_REDEFINE_OPERATOR_NEW |
42 | #endif | 52 | #endif |
43 | 53 | ||
44 | 54 | ||
45 | #ifdef _7ZIP_REDEFINE_OPERATOR_NEW | 55 | #ifdef Z7_REDEFINE_OPERATOR_NEW |
46 | 56 | ||
47 | // std::bad_alloc can require additional DLL dependency. | 57 | // std::bad_alloc can require additional DLL dependency. |
48 | // So we don't define CNewException as std::bad_alloc here. | 58 | // So we don't define CNewException as std::bad_alloc here. |