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
@@ -21,9 +21,10 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall
LOCAL_STATIC_LIBRARIES :=
LOCAL_SHARED_LIBRARIES := glog libglog_init
LOCAL_SHARED_LIBRARIES := glog libglog_init libreact_debug
include $(BUILD_SHARED_LIBRARY)
$(call import-module,glog)
$(call import-module,fbgloginit)
$(call import-module,react/debug)
@@ -52,6 +52,7 @@ rn_xplat_cxx_library(
"//xplat/fbsystrace:fbsystrace",
"//xplat/folly:headers_only",
"//xplat/folly:memory",
react_native_xplat_target("react/debug:debug"),
],
)
@@ -70,6 +71,7 @@ fb_xplat_cxx_test(
deps = [
"//xplat/folly:molly",
"//xplat/third-party/gmock:gtest",
react_native_xplat_target("react/debug:debug"),
react_native_xplat_target("react/renderer/mapbuffer:mapbuffer"),
],
)
@@ -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_;
@@ -7,6 +7,7 @@
#pragma once
#include <react/debug/react_native_assert.h>
#include <react/renderer/mapbuffer/MapBuffer.h>
#include <react/renderer/mapbuffer/primitives.h>
#include <stdlib.h>