From a75ec1153cb26e566e01de7ef3ab1fe3c1191314 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Thu, 29 Sep 2016 04:09:56 -0700 Subject: [PATCH] Free memory used in tests to enable use of valgrind Reviewed By: javache Differential Revision: D3937493 fbshipit-source-id: 23c6970d7769b081575d39de583ba954fc65a397 --- React/CSSLayout/CSSLayout.c | 9 +++++++++ React/CSSLayout/CSSLayout.h | 1 + 2 files changed, 10 insertions(+) diff --git a/React/CSSLayout/CSSLayout.c b/React/CSSLayout/CSSLayout.c index 84c51e79d..967647b22 100644 --- a/React/CSSLayout/CSSLayout.c +++ b/React/CSSLayout/CSSLayout.c @@ -142,6 +142,15 @@ void CSSNodeFree(const CSSNodeRef node) { free(node); } +void CSSNodeFreeRecursive(const CSSNodeRef root) { + while (CSSNodeChildCount(root) > 0) { + const CSSNodeRef child = CSSNodeGetChild(root, 0); + CSSNodeRemoveChild(root, child); + CSSNodeFreeRecursive(child); + } + CSSNodeFree(root); +} + void CSSNodeInit(const CSSNodeRef node) { node->parent = NULL; node->children = CSSNodeListNew(4); diff --git a/React/CSSLayout/CSSLayout.h b/React/CSSLayout/CSSLayout.h index 37c24d935..fd18f2769 100644 --- a/React/CSSLayout/CSSLayout.h +++ b/React/CSSLayout/CSSLayout.h @@ -126,6 +126,7 @@ typedef void (*CSSPrintFunc)(void *context); WIN_EXPORT CSSNodeRef CSSNodeNew(); WIN_EXPORT void CSSNodeInit(const CSSNodeRef node); WIN_EXPORT void CSSNodeFree(const CSSNodeRef node); +WIN_EXPORT void CSSNodeFreeRecursive(const CSSNodeRef node); WIN_EXPORT void CSSNodeInsertChild(const CSSNodeRef node, const CSSNodeRef child, const uint32_t index); WIN_EXPORT void CSSNodeRemoveChild(const CSSNodeRef node, const CSSNodeRef child);