Skip to content

Commit

Permalink
Free memory used in tests to enable use of valgrind
Browse files Browse the repository at this point in the history
Reviewed By: javache

Differential Revision: D3937493

fbshipit-source-id: 23c6970d7769b081575d39de583ba954fc65a397
  • Loading branch information
Emil Sjolander authored and Facebook Github Bot committed Sep 29, 2016
1 parent 0eea9c6 commit a75ec11
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions React/CSSLayout/CSSLayout.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions React/CSSLayout/CSSLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a75ec11

Please sign in to comment.