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,
|
||||
|
Reference in New Issue
Block a user