Summary: X-link: https://github.com/facebook/react-native/pull/41346 Pull Request resolved: https://github.com/facebook/yoga/pull/1452 This removes the last remnant from `Yoga-interna.h`, `YGNodeDellocate()`. The API is renamed to `YGNodeFinalize` to give it the explicit purpose of freeing the node from a garbage collector, and made public with that documented contract. With that, every top-level header is now a public API, and Yoga's JNI bindings do not need to rely on private headers anymore. Changelog: [Internal] Reviewed By: joevilches Differential Revision: D51014340 fbshipit-source-id: 553f04b62c78b76f9102cd6197146650955aeec5
36 lines
745 B
Java
36 lines
745 B
Java
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
package com.facebook.yoga;
|
|
|
|
public class YogaNodeJNIFinalizer extends YogaNodeJNIBase {
|
|
public YogaNodeJNIFinalizer() {
|
|
super();
|
|
}
|
|
|
|
public YogaNodeJNIFinalizer(YogaConfig config) {
|
|
super(config);
|
|
}
|
|
|
|
@Override
|
|
protected void finalize() throws Throwable {
|
|
try {
|
|
freeNatives();
|
|
} finally {
|
|
super.finalize();
|
|
}
|
|
}
|
|
|
|
public void freeNatives() {
|
|
if (mNativePointer != 0) {
|
|
long nativePointer = mNativePointer;
|
|
mNativePointer = 0;
|
|
YogaNative.jni_YGNodeFinalizeJNI(nativePointer);
|
|
}
|
|
}
|
|
}
|