]> Git Repo - VerusCoin.git/blobdiff - src/prevector.h
Ensure export finalization edge case
[VerusCoin.git] / src / prevector.h
index 3e80ef5d336458807903451403c9aec463fc90c5..aad4c27174fdbd939ba08e0ffe880f97e4efbec8 100644 (file)
@@ -1,6 +1,9 @@
 #ifndef _BITCOIN_PREVECTOR_H_
 #define _BITCOIN_PREVECTOR_H_
 
+#include <util.h>
+
+#include <assert.h>
 #include <stdlib.h>
 #include <stdint.h>
 #include <string.h>
@@ -166,10 +169,15 @@ private:
             }
         } else {
             if (!is_direct()) {
+                /* FIXME: Because malloc/realloc here won't call new_handler if allocation fails, assert
+                    success. These should instead use an allocator or new/delete so that handlers
+                    are called as necessary, but performance would be slightly degraded by doing so. */
                 _union.indirect = static_cast<char*>(realloc(_union.indirect, ((size_t)sizeof(T)) * new_capacity));
+                if (!_union.indirect) { new_handler_terminate(); }
                 _union.capacity = new_capacity;
             } else {
                 char* new_indirect = static_cast<char*>(malloc(((size_t)sizeof(T)) * new_capacity));
+                if (!new_indirect) { new_handler_terminate(); }
                 T* src = direct_ptr(0);
                 T* dst = reinterpret_cast<T*>(new_indirect);
                 memcpy(dst, src, size() * sizeof(T));
This page took 0.022549 seconds and 4 git commands to generate.