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

@@ -43,6 +43,8 @@ TEST(CSSLayoutTest, dont_measure_single_grow_shrink_child) {
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, measureCount);
CSSNodeFreeRecursive(root);
}
#if GTEST_HAS_DEATH_TEST
@@ -52,6 +54,7 @@ TEST(CSSLayoutTest, cannot_add_child_to_node_with_measure_func) {
const CSSNodeRef root_child0 = CSSNodeNew();
ASSERT_DEATH(CSSNodeInsertChild(root, root_child0, 0), "Cannot add child.*");
CSSNodeFree(root_child0);
CSSNodeFreeRecursive(root);
}