Create a recursive free with cleanup function
Reviewed By: davidaurelio Differential Revision: D13119307 fbshipit-source-id: 162bb4fd6d7620f61cbac010d0dc236d81738b71
This commit is contained in:
committed by
Facebook Github Bot
parent
8e48edaa0b
commit
9725d5b21b
@@ -319,7 +319,9 @@ static void YGConfigFreeRecursive(const YGNodeRef root) {
|
||||
}
|
||||
}
|
||||
|
||||
void YGNodeFreeRecursive(const YGNodeRef root) {
|
||||
void YGNodeFreeRecursiveWithCleanupFunc(
|
||||
const YGNodeRef root,
|
||||
YGNodeCleanupFunc cleanup) {
|
||||
while (YGNodeGetChildCount(root) > 0) {
|
||||
const YGNodeRef child = YGNodeGetChild(root, 0);
|
||||
if (child->getOwner() != root) {
|
||||
@@ -329,9 +331,16 @@ void YGNodeFreeRecursive(const YGNodeRef root) {
|
||||
YGNodeRemoveChild(root, child);
|
||||
YGNodeFreeRecursive(child);
|
||||
}
|
||||
if (cleanup != nullptr) {
|
||||
cleanup(root);
|
||||
}
|
||||
YGNodeFree(root);
|
||||
}
|
||||
|
||||
void YGNodeFreeRecursive(const YGNodeRef root) {
|
||||
return YGNodeFreeRecursiveWithCleanupFunc(root, nullptr);
|
||||
}
|
||||
|
||||
void YGNodeReset(const YGNodeRef node) {
|
||||
YGAssertWithNode(
|
||||
node,
|
||||
|
@@ -70,6 +70,7 @@ typedef float (
|
||||
*YGBaselineFunc)(YGNodeRef node, const float width, const float height);
|
||||
typedef void (*YGDirtiedFunc)(YGNodeRef node);
|
||||
typedef void (*YGPrintFunc)(YGNodeRef node);
|
||||
typedef void (*YGNodeCleanupFunc)(YGNodeRef node);
|
||||
typedef int (*YGLogger)(
|
||||
const YGConfigRef config,
|
||||
const YGNodeRef node,
|
||||
@@ -84,6 +85,9 @@ WIN_EXPORT YGNodeRef YGNodeNew(void);
|
||||
WIN_EXPORT YGNodeRef YGNodeNewWithConfig(const YGConfigRef config);
|
||||
WIN_EXPORT YGNodeRef YGNodeClone(const YGNodeRef node);
|
||||
WIN_EXPORT void YGNodeFree(const YGNodeRef node);
|
||||
WIN_EXPORT void YGNodeFreeRecursiveWithCleanupFunc(
|
||||
const YGNodeRef node,
|
||||
YGNodeCleanupFunc cleanup);
|
||||
WIN_EXPORT void YGNodeFreeRecursive(const YGNodeRef node);
|
||||
WIN_EXPORT void YGNodeReset(const YGNodeRef node);
|
||||
WIN_EXPORT int32_t YGNodeGetInstanceCount(void);
|
||||
|
Reference in New Issue
Block a user