Integrate react_native_asserts into mapbuffer

Summary:
Integrate react_native_asserts into mapbuffer

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D27753092

fbshipit-source-id: dbeb7f140f3096c8153e2f6bced4e4d9d88b48b8
This commit is contained in:
David Vacca
2021-04-13 21:32:17 -07:00
committed by Facebook GitHub Bot
parent e57de5f32f
commit aee07e1203
4 changed files with 8 additions and 7 deletions
@@ -33,12 +33,9 @@ MapBufferBuilder::MapBufferBuilder(uint16_t initialSize) {
void MapBufferBuilder::ensureKeyValueSpace() {
int oldKeyValuesSize = keyValuesSize_;
if (keyValuesSize_ >= std::numeric_limits<uint16_t>::max() / 2) {
LOG(ERROR)
<< "Error: trying to assign a value beyond the capacity of uint16_t"
<< static_cast<uint32_t>(keyValuesSize_) * 2;
abort();
}
react_native_assert(
(keyValuesSize_ >= std::numeric_limits<uint16_t>::max() / 2) &&
"Error trying to assign a value beyond the capacity of uint16_t");
keyValuesSize_ *= 2;
uint8_t *newKeyValues = new Byte[keyValuesSize_];
uint8_t *oldKeyValues = keyValues_;