diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-03-25 17:53:14 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-03-25 17:53:14 +0100 |
commit | f2902217b38cf2e16e851ae84d61247f8e828180 (patch) | |
tree | 0156a6db6aa8b4d87bf041ece5cf5229c59fe9de /other-licenses/7zstub/src/CPP/Common/NewHandler.h | |
parent | 917a2c450f08ab4c934c9938319f10a1114272b4 (diff) | |
download | UXP-f2902217b38cf2e16e851ae84d61247f8e828180.tar UXP-f2902217b38cf2e16e851ae84d61247f8e828180.tar.gz UXP-f2902217b38cf2e16e851ae84d61247f8e828180.tar.lz UXP-f2902217b38cf2e16e851ae84d61247f8e828180.tar.xz UXP-f2902217b38cf2e16e851ae84d61247f8e828180.zip |
Update the 7z installer stub source to 18.05.
Tag #1022
Diffstat (limited to 'other-licenses/7zstub/src/CPP/Common/NewHandler.h')
-rw-r--r-- | other-licenses/7zstub/src/CPP/Common/NewHandler.h | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/other-licenses/7zstub/src/CPP/Common/NewHandler.h b/other-licenses/7zstub/src/CPP/Common/NewHandler.h new file mode 100644 index 000000000..9d20ee134 --- /dev/null +++ b/other-licenses/7zstub/src/CPP/Common/NewHandler.h @@ -0,0 +1,88 @@ +// Common/NewHandler.h
+
+#ifndef __COMMON_NEW_HANDLER_H
+#define __COMMON_NEW_HANDLER_H
+
+/*
+NewHandler.h and NewHandler.cpp allows to solve problem with compilers that
+don't throw exception in operator new().
+
+This file must be included before any code that uses operators new() or delete()
+and you must compile and link "NewHandler.cpp", if you use some old MSVC compiler.
+
+The operator new() in some MSVC versions doesn't throw exception std::bad_alloc.
+MSVC 6.0 (_MSC_VER == 1200) doesn't throw exception.
+The code produced by some another MSVC compilers also can be linked
+to library that doesn't throw exception.
+We suppose that code compiled with VS2015+ (_MSC_VER >= 1900) throws exception std::bad_alloc.
+For older _MSC_VER versions we redefine operator new() and operator delete().
+Our version of operator new() throws CNewException() exception on failure.
+
+It's still allowed to use redefined version of operator new() from "NewHandler.cpp"
+with any compiler. 7-Zip's code can work with std::bad_alloc and CNewException() exceptions.
+But if you use some additional code (outside of 7-Zip's code), you must check
+that redefined version of operator new() is not problem for your code.
+*/
+
+#include <stddef.h>
+
+#ifdef _WIN32
+// We can compile my_new and my_delete with _fastcall
+/*
+void * my_new(size_t size);
+void my_delete(void *p) throw();
+// void * my_Realloc(void *p, size_t newSize, size_t oldSize);
+*/
+#endif
+
+
+#if defined(_MSC_VER) && (_MSC_VER < 1900)
+ // If you want to use default operator new(), you can disable the following line
+ #define _7ZIP_REDEFINE_OPERATOR_NEW
+#endif
+
+
+#ifdef _7ZIP_REDEFINE_OPERATOR_NEW
+
+// std::bad_alloc can require additional DLL dependency.
+// So we don't define CNewException as std::bad_alloc here.
+
+class CNewException {};
+
+void *
+#ifdef _MSC_VER
+__cdecl
+#endif
+operator new(size_t size);
+
+void
+#ifdef _MSC_VER
+__cdecl
+#endif
+operator delete(void *p) throw();
+
+#else
+
+#include <new>
+
+#define CNewException std::bad_alloc
+
+#endif
+
+/*
+#ifdef _WIN32
+void *
+#ifdef _MSC_VER
+__cdecl
+#endif
+operator new[](size_t size);
+
+void
+#ifdef _MSC_VER
+__cdecl
+#endif
+operator delete[](void *p) throw();
+#endif
+*/
+
+#endif
|