Remove init from api
Reviewed By: gkassabli Differential Revision: D4276177 fbshipit-source-id: c4404d0534f381dfacee0625b2847d38de58e038
This commit is contained in:
parent
d3065f6895
commit
a47678b3e9
|
@ -185,57 +185,7 @@ static inline float YGComputedEdgeValue(const float edges[YGEdgeCount],
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t gNodeInstanceCount = 0;
|
static void YGNodeInit(const YGNodeRef node) {
|
||||||
|
|
||||||
YGNodeRef YGNodeNew(void) {
|
|
||||||
const YGNodeRef node = gYGCalloc(1, sizeof(YGNode));
|
|
||||||
YG_ASSERT(node, "Could not allocate memory for node");
|
|
||||||
gNodeInstanceCount++;
|
|
||||||
|
|
||||||
YGNodeInit(node);
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
void YGNodeFree(const YGNodeRef node) {
|
|
||||||
if (node->parent) {
|
|
||||||
YGNodeListDelete(node->parent->children, node);
|
|
||||||
node->parent = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
const uint32_t childCount = YGNodeChildCount(node);
|
|
||||||
for (uint32_t i = 0; i < childCount; i++) {
|
|
||||||
const YGNodeRef child = YGNodeGetChild(node, i);
|
|
||||||
child->parent = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
YGNodeListFree(node->children);
|
|
||||||
gYGFree(node);
|
|
||||||
gNodeInstanceCount--;
|
|
||||||
}
|
|
||||||
|
|
||||||
void YGNodeFreeRecursive(const YGNodeRef root) {
|
|
||||||
while (YGNodeChildCount(root) > 0) {
|
|
||||||
const YGNodeRef child = YGNodeGetChild(root, 0);
|
|
||||||
YGNodeRemoveChild(root, child);
|
|
||||||
YGNodeFreeRecursive(child);
|
|
||||||
}
|
|
||||||
YGNodeFree(root);
|
|
||||||
}
|
|
||||||
|
|
||||||
void YGNodeReset(const YGNodeRef node) {
|
|
||||||
YG_ASSERT(YGNodeChildCount(node) == 0, "Cannot reset a node which still has children attached");
|
|
||||||
YG_ASSERT(node->parent == NULL, "Cannot reset a node still attached to a parent");
|
|
||||||
|
|
||||||
YGNodeListFree(node->children);
|
|
||||||
memset(node, 0, sizeof(YGNode));
|
|
||||||
YGNodeInit(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t YGNodeGetInstanceCount(void) {
|
|
||||||
return gNodeInstanceCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
void YGNodeInit(const YGNodeRef node) {
|
|
||||||
node->parent = NULL;
|
node->parent = NULL;
|
||||||
node->children = NULL;
|
node->children = NULL;
|
||||||
node->hasNewLayout = true;
|
node->hasNewLayout = true;
|
||||||
|
@ -289,6 +239,56 @@ void YGNodeInit(const YGNodeRef node) {
|
||||||
node->layout.cachedLayout.computedHeight = -1;
|
node->layout.cachedLayout.computedHeight = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t gNodeInstanceCount = 0;
|
||||||
|
|
||||||
|
YGNodeRef YGNodeNew(void) {
|
||||||
|
const YGNodeRef node = gYGCalloc(1, sizeof(YGNode));
|
||||||
|
YG_ASSERT(node, "Could not allocate memory for node");
|
||||||
|
gNodeInstanceCount++;
|
||||||
|
|
||||||
|
YGNodeInit(node);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeFree(const YGNodeRef node) {
|
||||||
|
if (node->parent) {
|
||||||
|
YGNodeListDelete(node->parent->children, node);
|
||||||
|
node->parent = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint32_t childCount = YGNodeChildCount(node);
|
||||||
|
for (uint32_t i = 0; i < childCount; i++) {
|
||||||
|
const YGNodeRef child = YGNodeGetChild(node, i);
|
||||||
|
child->parent = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
YGNodeListFree(node->children);
|
||||||
|
gYGFree(node);
|
||||||
|
gNodeInstanceCount--;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeFreeRecursive(const YGNodeRef root) {
|
||||||
|
while (YGNodeChildCount(root) > 0) {
|
||||||
|
const YGNodeRef child = YGNodeGetChild(root, 0);
|
||||||
|
YGNodeRemoveChild(root, child);
|
||||||
|
YGNodeFreeRecursive(child);
|
||||||
|
}
|
||||||
|
YGNodeFree(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeReset(const YGNodeRef node) {
|
||||||
|
YG_ASSERT(YGNodeChildCount(node) == 0, "Cannot reset a node which still has children attached");
|
||||||
|
YG_ASSERT(node->parent == NULL, "Cannot reset a node still attached to a parent");
|
||||||
|
|
||||||
|
YGNodeListFree(node->children);
|
||||||
|
memset(node, 0, sizeof(YGNode));
|
||||||
|
YGNodeInit(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t YGNodeGetInstanceCount(void) {
|
||||||
|
return gNodeInstanceCount;
|
||||||
|
}
|
||||||
|
|
||||||
static void YGNodeMarkDirtyInternal(const YGNodeRef node) {
|
static void YGNodeMarkDirtyInternal(const YGNodeRef node) {
|
||||||
if (!node->isDirty) {
|
if (!node->isDirty) {
|
||||||
node->isDirty = true;
|
node->isDirty = true;
|
||||||
|
|
|
@ -54,7 +54,6 @@ typedef void (*YGFree)(void *ptr);
|
||||||
|
|
||||||
// YGNode
|
// YGNode
|
||||||
WIN_EXPORT YGNodeRef YGNodeNew(void);
|
WIN_EXPORT YGNodeRef YGNodeNew(void);
|
||||||
WIN_EXPORT void YGNodeInit(const YGNodeRef node);
|
|
||||||
WIN_EXPORT void YGNodeFree(const YGNodeRef node);
|
WIN_EXPORT void YGNodeFree(const YGNodeRef node);
|
||||||
WIN_EXPORT void YGNodeFreeRecursive(const YGNodeRef node);
|
WIN_EXPORT void YGNodeFreeRecursive(const YGNodeRef node);
|
||||||
WIN_EXPORT void YGNodeReset(const YGNodeRef node);
|
WIN_EXPORT void YGNodeReset(const YGNodeRef node);
|
||||||
|
|
Loading…
Reference in New Issue