From 208e4d2dcdbf5a2ef91294252ca3d5a039dff524 Mon Sep 17 00:00:00 2001 From: Vitaly Potlov Date: Wed, 24 Jun 2020 12:27:35 -0700 Subject: [PATCH] Fix static method in file header (#29118) Summary: I have looked into recent commits and found a typical mistake when static is used in .h file. Here static is not necessary. See link: https://stackoverflow.com/questions/780730/c-c-static-function-in-header-file-what-does-it-mean ## Changelog Changelog: [Internal] Fabric-specific internal change. Pull Request resolved: https://github.com/facebook/react-native/pull/29118 Reviewed By: sammy-SC Differential Revision: D22039305 Pulled By: shergin fbshipit-source-id: 7078e716166067dd1e94cbb84200a1235283c978 --- ReactCommon/utils/ManagedObjectWrapper.h | 13 +------------ ReactCommon/utils/ManagedObjectWrapper.mm | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/ReactCommon/utils/ManagedObjectWrapper.h b/ReactCommon/utils/ManagedObjectWrapper.h index 005638d087..6231580157 100644 --- a/ReactCommon/utils/ManagedObjectWrapper.h +++ b/ReactCommon/utils/ManagedObjectWrapper.h @@ -27,18 +27,7 @@ namespace detail { * A custom deleter used for the deallocation of Objective-C managed objects. * To be used only by `wrapManagedObject`. */ -static void wrappedManagedObjectDeleter(void *cfPointer) noexcept -{ - // A shared pointer does call custom deleter on `nullptr`s. - // This is somewhat counter-intuitively but makes sense considering the type-erasured nature of shared pointer and an - // aliasing constructor feature. `CFRelease` crashes on null pointer though. Therefore we must check for this case - // explicitly. - if (cfPointer == NULL) { - return; - } - - CFRelease(cfPointer); -} +void wrappedManagedObjectDeleter(void *cfPointer) noexcept; } diff --git a/ReactCommon/utils/ManagedObjectWrapper.mm b/ReactCommon/utils/ManagedObjectWrapper.mm index 1a6822eca6..ede1d30aad 100644 --- a/ReactCommon/utils/ManagedObjectWrapper.mm +++ b/ReactCommon/utils/ManagedObjectWrapper.mm @@ -10,6 +10,27 @@ #if defined(__OBJC__) && defined(__cplusplus) #if TARGET_OS_MAC && TARGET_OS_IPHONE +namespace facebook { +namespace react { +namespace detail { + +void wrappedManagedObjectDeleter(void *cfPointer) noexcept +{ + // A shared pointer does call custom deleter on `nullptr`s. + // This is somewhat counter-intuitively but makes sense considering the type-erasured nature of shared pointer and an + // aliasing constructor feature. `CFRelease` crashes on null pointer though. Therefore we must check for this case + // explicitly. + if (cfPointer == NULL) { + return; + } + + CFRelease(cfPointer); +} + +} // namespace detail +} // namespace react +} // namespace facebook + @implementation RCTInternalGenericWeakWrapper @end