Skip to content

Commit

Permalink
Integrate react_native_asserts into mapbuffer
Browse files Browse the repository at this point in the history
Summary:
Integrate react_native_asserts into mapbuffer

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D27753092

fbshipit-source-id: dbeb7f140f3096c8153e2f6bced4e4d9d88b48b8
  • Loading branch information
mdvacca authored and facebook-github-bot committed Apr 14, 2021
1 parent e57de5f commit aee07e1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion ReactCommon/react/renderer/mapbuffer/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 2 additions & 0 deletions ReactCommon/react/renderer/mapbuffer/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
],
)

Expand All @@ -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"),
],
)
9 changes: 3 additions & 6 deletions ReactCommon/react/renderer/mapbuffer/MapBufferBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down
1 change: 1 addition & 0 deletions ReactCommon/react/renderer/mapbuffer/MapBufferBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit aee07e1

Please sign in to comment.