Attempt to log before terminating if prevector allocation fails

This commit is contained in:
Jack Grigg
2018-04-26 11:30:33 +01:00
parent 3c9dbf3ed8
commit aeb089ecc7
4 changed files with 21 additions and 16 deletions

View File

@@ -1,6 +1,8 @@
#ifndef _BITCOIN_PREVECTOR_H_
#define _BITCOIN_PREVECTOR_H_
#include <util.h>
#include <assert.h>
#include <stdlib.h>
#include <stdint.h>
@@ -171,11 +173,11 @@ private:
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));
assert(_union.indirect);
if (!_union.indirect) { new_handler_terminate(); }
_union.capacity = new_capacity;
} else {
char* new_indirect = static_cast<char*>(malloc(((size_t)sizeof(T)) * new_capacity));
assert(new_indirect);
if (!new_indirect) { new_handler_terminate(); }
T* src = direct_ptr(0);
T* dst = reinterpret_cast<T*>(new_indirect);
memcpy(dst, src, size() * sizeof(T));