diff options
Diffstat (limited to 'CPP/Common')
| -rw-r--r-- | CPP/Common/Common0.h | 5 | ||||
| -rw-r--r-- | CPP/Common/MyBuffer.h | 48 |
2 files changed, 50 insertions, 3 deletions
diff --git a/CPP/Common/Common0.h b/CPP/Common/Common0.h index 55606cd..5781a95 100644 --- a/CPP/Common/Common0.h +++ b/CPP/Common/Common0.h | |||
| @@ -126,8 +126,9 @@ if compiled with new GCC libstdc++, GCC libstdc++ can use: | |||
| 126 | #pragma GCC diagnostic ignored "-Wglobal-constructors" | 126 | #pragma GCC diagnostic ignored "-Wglobal-constructors" |
| 127 | #pragma GCC diagnostic ignored "-Wexit-time-destructors" | 127 | #pragma GCC diagnostic ignored "-Wexit-time-destructors" |
| 128 | 128 | ||
| 129 | #if defined(Z7_LLVM_CLANG_VERSION) && __clang_major__ >= 18 // 18.1.0RC | 129 | #if defined(Z7_LLVM_CLANG_VERSION) && __clang_major__ >= 18 /* 18.1.0RC */ \ |
| 130 | #pragma GCC diagnostic ignored "-Wswitch-default" | 130 | || defined(Z7_APPLE_CLANG_VERSION) && __clang_major__ >= 16 // for APPLE=17 (LLVM=19) |
| 131 | #pragma GCC diagnostic ignored "-Wswitch-default" | ||
| 131 | #endif | 132 | #endif |
| 132 | // #pragma GCC diagnostic ignored "-Wunused-private-field" | 133 | // #pragma GCC diagnostic ignored "-Wunused-private-field" |
| 133 | // #pragma GCC diagnostic ignored "-Wnonportable-system-include-path" | 134 | // #pragma GCC diagnostic ignored "-Wnonportable-system-include-path" |
diff --git a/CPP/Common/MyBuffer.h b/CPP/Common/MyBuffer.h index 80f0205..08c10a3 100644 --- a/CPP/Common/MyBuffer.h +++ b/CPP/Common/MyBuffer.h | |||
| @@ -202,7 +202,53 @@ public: | |||
| 202 | } | 202 | } |
| 203 | }; | 203 | }; |
| 204 | 204 | ||
| 205 | typedef CObjArray<Byte> CByteArr; | 205 | |
| 206 | /* CSmallObjArray can be used for Byte arrays | ||
| 207 | or for arrays whose total size in bytes does not exceed size_t ranges. | ||
| 208 | So there is no need to use Z7_ARRAY_NEW macro in CSmallObjArray code. */ | ||
| 209 | template <class T> class CSmallObjArray | ||
| 210 | { | ||
| 211 | protected: | ||
| 212 | T *_items; | ||
| 213 | private: | ||
| 214 | // we disable copy | ||
| 215 | CSmallObjArray(const CSmallObjArray &buffer); | ||
| 216 | void operator=(const CSmallObjArray &buffer); | ||
| 217 | public: | ||
| 218 | void Free() | ||
| 219 | { | ||
| 220 | delete []_items; | ||
| 221 | _items = NULL; | ||
| 222 | } | ||
| 223 | CSmallObjArray(size_t size): _items(NULL) | ||
| 224 | { | ||
| 225 | if (size != 0) | ||
| 226 | { | ||
| 227 | // Z7_ARRAY_NEW(_items, T, size) | ||
| 228 | _items = new T[size]; | ||
| 229 | } | ||
| 230 | } | ||
| 231 | CSmallObjArray(): _items(NULL) {} | ||
| 232 | ~CSmallObjArray() { delete []_items; } | ||
| 233 | |||
| 234 | operator T *() { return _items; } | ||
| 235 | operator const T *() const { return _items; } | ||
| 236 | const T* ConstData() const { return _items; } | ||
| 237 | T* NonConstData() const { return _items; } | ||
| 238 | T* NonConstData() { return _items; } | ||
| 239 | // const T* Data() const { return _items; } | ||
| 240 | // T* Data() { return _items; } | ||
| 241 | |||
| 242 | void Alloc(size_t newSize) | ||
| 243 | { | ||
| 244 | delete []_items; | ||
| 245 | _items = NULL; | ||
| 246 | // Z7_ARRAY_NEW(_items, T, newSize) | ||
| 247 | _items = new T[newSize]; | ||
| 248 | } | ||
| 249 | }; | ||
| 250 | |||
| 251 | typedef CSmallObjArray<Byte> CByteArr; | ||
| 206 | typedef CObjArray<bool> CBoolArr; | 252 | typedef CObjArray<bool> CBoolArr; |
| 207 | typedef CObjArray<int> CIntArr; | 253 | typedef CObjArray<int> CIntArr; |
| 208 | typedef CObjArray<unsigned> CUIntArr; | 254 | typedef CObjArray<unsigned> CUIntArr; |
