Breaking: YGConfigRef related const-correctness fixes (#1371)
Summary: X-link: https://github.com/facebook/react-native/pull/39374 Pull Request resolved: https://github.com/facebook/yoga/pull/1371 Right now `YGConfigGetDefault` and `YGNodeGetConfig` both return mutable, freeable, configs, which is bad, since the former points to a global singleton config, and the latter usually does too. Mutating this is not thread safe, and it should never be freed. This change makes these functions return `YGConfigConstRef` to prevent mutation, and also lets us allow `YGConfigNewWithConfig` to accept a const config. If a caller does want to mutate a config (such as to free it), it must be tracked manually. Changelog: [Internal] Reviewed By: javache Differential Revision: D49132476 fbshipit-source-id: ac9ce61149e69c6c25cadb99711435b0a5b9f38a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
a003c09a4c
commit
0720e0b22a
@@ -52,7 +52,7 @@ typedef YGNodeRef (*YGCloneNodeFunc)(
|
||||
|
||||
// YGNode
|
||||
WIN_EXPORT YGNodeRef YGNodeNew(void);
|
||||
WIN_EXPORT YGNodeRef YGNodeNewWithConfig(YGConfigRef config);
|
||||
WIN_EXPORT YGNodeRef YGNodeNewWithConfig(YGConfigConstRef config);
|
||||
WIN_EXPORT YGNodeRef YGNodeClone(YGNodeConstRef node);
|
||||
WIN_EXPORT void YGNodeFree(YGNodeRef node);
|
||||
WIN_EXPORT void YGNodeFreeRecursiveWithCleanupFunc(
|
||||
@@ -131,7 +131,7 @@ WIN_EXPORT void YGNodeCopyStyle(YGNodeRef dstNode, YGNodeConstRef srcNode);
|
||||
WIN_EXPORT void* YGNodeGetContext(YGNodeConstRef node);
|
||||
WIN_EXPORT void YGNodeSetContext(YGNodeRef node, void* context);
|
||||
|
||||
WIN_EXPORT YGConfigRef YGNodeGetConfig(YGNodeRef node);
|
||||
WIN_EXPORT YGConfigConstRef YGNodeGetConfig(YGNodeRef node);
|
||||
WIN_EXPORT void YGNodeSetConfig(YGNodeRef node, YGConfigRef config);
|
||||
|
||||
void YGConfigSetPrintTreeFlag(YGConfigRef config, bool enabled);
|
||||
@@ -327,7 +327,7 @@ WIN_EXPORT void YGConfigSetCloneNodeFunc(
|
||||
YGConfigRef config,
|
||||
YGCloneNodeFunc callback);
|
||||
|
||||
WIN_EXPORT YGConfigRef YGConfigGetDefault(void);
|
||||
WIN_EXPORT YGConfigConstRef YGConfigGetDefault(void);
|
||||
|
||||
WIN_EXPORT void YGConfigSetContext(YGConfigRef config, void* context);
|
||||
WIN_EXPORT void* YGConfigGetContext(YGConfigConstRef config);
|
||||
|
Reference in New Issue
Block a user