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