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

@@ -47,6 +47,11 @@ typedef CSSSize (*CSSMeasureFunc)(CSSNodeRef node,
typedef void (*CSSPrintFunc)(CSSNodeRef node);
typedef int (*CSSLogger)(CSSLogLevel level, const char *format, va_list args);
typedef void *(*CSSMalloc)(size_t size);
typedef void *(*CSSCalloc)(size_t count, size_t size);
typedef void *(*CSSRealloc)(void *ptr, size_t size);
typedef void (*CSSFree)(void *ptr);
// CSSNode
WIN_EXPORT CSSNodeRef CSSNodeNew(void);
WIN_EXPORT void CSSNodeInit(const CSSNodeRef node);
@@ -156,4 +161,9 @@ WIN_EXPORT void CSSLog(CSSLogLevel level, const char *message, ...);
WIN_EXPORT void CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature feature, bool enabled);
WIN_EXPORT bool CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeature feature);
WIN_EXPORT void CSSLayoutSetMemoryFuncs(CSSMalloc cssMalloc,
CSSCalloc cssCalloc,
CSSRealloc cssRealloc,
CSSFree cssFree);
CSS_EXTERN_C_END