Introduce CSSLayoutSetMemoryFuncs

Summary:
- Add CSSLayoutSetMemoryFuncs function which allows application to replace malloc, calloc, realloc and free with application's functions, like zalloc and zfree of zlib.
- Fixed memory leaks in tests.
- Close #247

For example, to use dlmalloc with USE_DL_PREFIX

    CSSLayoutSetMemoryFuncs(&dlmalloc, &dlcalloc, &dlrealloc, &dlfree);

Reviewed By: emilsjolander

Differential Revision: D4178386

fbshipit-source-id: a79dbdaf82a512f42cc43f99dbc49faba296903b
This commit is contained in:
Kazuki Sakamoto
2016-11-15 20:20:09 -08:00
committed by Facebook Github Bot
parent 667858990c
commit ef81d4b0c7
6 changed files with 127 additions and 8 deletions

View File

@@ -83,11 +83,14 @@ TEST(CSSLayoutTest, dirty_node_only_if_children_are_actually_removed) {
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
CSSNodeRemoveChild(root, CSSNodeNew());
const CSSNodeRef child1 = CSSNodeNew();
CSSNodeRemoveChild(root, child1);
EXPECT_FALSE(CSSNodeIsDirty(root));
CSSNodeFree(child1);
CSSNodeRemoveChild(root, child0);
EXPECT_TRUE(CSSNodeIsDirty(root));
CSSNodeFree(child0);
CSSNodeFreeRecursive(root);
}