本文整理汇总了C++中FreeNode函数的典型用法代码示例。如果您正苦于以下问题:C++ FreeNode函数的具体用法?C++ FreeNode怎么用?C++ FreeNode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FreeNode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Insert2List
E_BOOL_TYPE Insert2List(PT_NODE ptHeadNode, char* tagName, char* content)
{
PT_NODE ptNode = NULL;
PT_NODE ptFirst = NULL;
ptNode = (PT_NODE) malloc(sizeof(T_NODE));
if ( ptNode == NULL )
{
return FAIL;
}
ptNode->tagName = (char*)dupstr(tagName);
if ( !ptNode->tagName )
{
FreeNode(&ptNode);
return FAIL;
}
ptNode->content = (char*)dupstr(content);
if ( !ptNode->content )
{
FreeNode(&ptNode);
return FAIL;
}
ptFirst = ptHeadNode->next;
ptHeadNode->next = ptNode;
ptNode->next = ptFirst;
return SUCCESS;
}
示例2: FreeNode
/*
** FreeNode() recursively frees a given node.
*/
void FreeNode(node *n) {
if (n->type != TGEN && n->type != TNUM) {
FreeNode(n->cont.op.l);
FreeNode(n->cont.op.r);
}
Free(n);
}
示例3: Mul
NODE * Mul( NODE *n1, NODE *n2 )
{
if( n1 == 0 ) return n2;
if( n2 == 0 ) return n1;
if( IsConst( n1, 1 ) ) {
n2->sign *= n1->sign;
FreeNode( n1 );
return n2;
}
if( IsConst( n2, 1 ) ) {
n2->sign *= n1->sign;
FreeNode( n2 );
return n1;
}
if( IsConst( n1, 0 ) ) {
FreeNode( n2 );
return n1;
}
if( IsConst( n2, 0 ) ) {
FreeNode( n1 );
return n2;
}
return BinaryOp( MUL, n1, n2 );
}
示例4: MergeList
/**
* 算法2.21
*/
Status MergeList(LinkList &La, LinkList &Lb, LinkList &Lc,
int (*compare)(ElemType, ElemType))
{
Link ha, hb, pa, pb, q;
ElemType a, b;
if (!InitList(Lc))
return ERROR;
ha = GetHead(La);
hb = GetHead(Lb);
pa = NextPos(La, ha);
pb = NextPos(Lb, hb);
while (pa && pb) {
a = GetCurElem(pa);
b = GetCurElem(pb);
if (compare(a, b) <= 0) { // a<=b
DelFirst(ha, q);
Append(Lc, q);
pa = NextPos(La, ha);
} else { // a>b
DelFirst(hb, q);
Append(Lc, q);
pb = NextPos(Lb, hb);
}
} // while
if (pa)
Append(Lc, pa);
else
Append(Lc, pb);
FreeNode(ha);
FreeNode(hb);
return OK;
}
示例5: RmSubst
void RmSubst( NODE *n )
{
NODE *pn;
NODE *cn;
pn = 0;
cn = substList;
while( cn != 0 ) {
if( NodeCmp( n, cn ) )
break;
pn = cn;
cn = cn->left;
}
if( cn == 0 ) return;
FreeNode( cn->right );
if( pn )
pn->left = cn->left;
else
substList = cn->left;
cn->right = 0;
cn->left = 0;
FreeNode( cn );
}
示例6: DeleteItem
//************************************************
// 删除一个节点,可以被派生类重载
//***********************************************
virtual void DeleteItem(HSTREEITEM hItem)
{
HSTREENODE hsNode= (HSTREENODE)hItem;
DUIASSERT(hsNode);
if(hsNode==STVN_ROOT)
{
FreeNode(STVN_ROOT);
m_hRootFirst=NULL;
m_hRootLast=NULL;
return;
}
STREENODE nodeCopy=*hsNode;
BOOL bRootFirst=hsNode==m_hRootFirst;
BOOL bRootLast=hsNode==m_hRootLast;
FreeNode(hsNode);
if(nodeCopy.hPrevSibling)//has prevsibling
nodeCopy.hPrevSibling->hNextSibling=nodeCopy.hNextSibling;
else if(nodeCopy.hParent)//parent's first child
nodeCopy.hParent->hChildFirst=nodeCopy.hNextSibling;
if(nodeCopy.hNextSibling)// update next sibling's previous sibling
nodeCopy.hNextSibling->hPrevSibling=nodeCopy.hPrevSibling;
else if(nodeCopy.hParent)//parent's last child
nodeCopy.hParent->hChildLast=nodeCopy.hPrevSibling;
//update root item
if(bRootFirst) m_hRootFirst=nodeCopy.hNextSibling;
if(bRootLast) m_hRootLast=nodeCopy.hPrevSibling;
}
示例7: SortPolyn
void SortPolyn(polynomail *p) {
Link *p1, *p2; //采用直接插入排序
for (p1 = p->head->next; p1; p1 = p1->next) {
for (p2 = p->head->next; p2 != p1; p2 = p2->next) {
if (p2->data->expn == p1->data->expn) { //若后边待排序的节点的指数跟前面已排序
Link *pri; //节点的指数相同,则应该合并两项,即删除后者,并入前者
p2->data->coef += p1->data->coef;
pri = PriorPos(*p, p1);
DelFirst(pri, &p1);
FreeNode(p1);
--p->len;
if (fabs(p2->data->coef) < 1e-6) { //如果合并后系数为0,那也要把这个节点删除
pri = PriorPos(*p, p2);
DelFirst(pri, &p2);
FreeNode(p2);
--p->len;
}
p1 = pri;
break;
}
else if (p1->data->expn < p2->data->expn) {
Link *pri1, *pri2;
pri1 = PriorPos(*p, p1);
DelFirst(pri1, &p1);
pri2 = PriorPos(*p, p2);
InsFirst(pri2, p1);
p1 = pri1;
break;
}
}
}
p->tail = GetLast(*p);
}
示例8: AGetIdHashValue
/* Get the identity-based hash value for an object reference at *v. This may
cause the object to move, thus updating *v. */
AValue AGetIdHashValue(AThread *t, AValue *v)
{
void *p = AValueToPtr(*v);
HashMappingTable *table;
AValue hash;
if (AIsInNursery(p))
table = &NewGenTable;
else
table = &OldGenTable;
ALockHashMappings();
hash = GetHashMapping(table, p);
if (AIsError(hash)) {
/* Could not find a mapping -- insert a new hash mapping. */
int i;
HashValueNode *n;
/* Allocate a new hash node. Note that this may cause the object to be
moved, but we'll handle that case later. */
n = AllocNode(p);
if (n == NULL) {
/* Out of memory. */
AUnlockHashMappings();
return ARaiseMemoryErrorND(t);
}
/* Check if it is time to grow the hash table. This may cause the
object to be moved. */
if (table->num > table->size) {
if (!GrowHashTable(table)) {
/* Out of memory. */
FreeNode(n);
AUnlockHashMappings();
return ARaiseMemoryErrorND(t);
}
}
/* If the target value moved to the old generation, try again. */
if (p != AValueToPtr(*v)) {
FreeNode(n);
AUnlockHashMappings();
return AGetIdHashValue(t, v);
}
/* Calculate hash value for the internal hash table. */
i = PtrHashValue(p) & (table->size - 1);
/* Initialize the new table entry. */
n->next = table->table[i];
table->num++;
table->table[i] = n;
hash = n->hashValue;
}
AUnlockHashMappings();
return hash;
}
示例9: FreeNode
void FreeNode( NODE * n )
{
if( n == 0 ) return;
FreeNode( n->left );
FreeNode( n->right );
if( n->elm ) free( n->elm );
free( n );
}
示例10: FreeNode
void b2DynamicTree::RemoveLeaf(int32 leaf)
{
if (leaf == m_root)
{
m_root = b2_nullNode;
return;
}
int32 parent = m_nodes[leaf].parent;
int32 grandParent = m_nodes[parent].parent;
int32 sibling;
if (m_nodes[parent].child1 == leaf)
{
sibling = m_nodes[parent].child2;
}
else
{
sibling = m_nodes[parent].child1;
}
if (grandParent != b2_nullNode)
{
// Destroy parent and connect sibling to grandParent.
if (m_nodes[grandParent].child1 == parent)
{
m_nodes[grandParent].child1 = sibling;
}
else
{
m_nodes[grandParent].child2 = sibling;
}
m_nodes[sibling].parent = grandParent;
FreeNode(parent);
// Adjust ancestor bounds.
int32 index = grandParent;
while (index != b2_nullNode)
{
index = Balance(index);
int32 child1 = m_nodes[index].child1;
int32 child2 = m_nodes[index].child2;
m_nodes[index].aabb.Combine(m_nodes[child1].aabb, m_nodes[child2].aabb);
m_nodes[index].height = 1 + b2Max(m_nodes[child1].height, m_nodes[child2].height);
index = m_nodes[index].parent;
}
}
else
{
m_root = sibling;
m_nodes[sibling].parent = b2_nullNode;
FreeNode(parent);
}
//Validate();
}
示例11: FreeNode
void b2DynamicTree::RemoveLeaf(int32 leaf)
{
if (leaf == m_root)
{
m_root = b2_nullNode;
return;
}
int32 node2 = m_nodes[leaf].parent;
int32 node1 = m_nodes[node2].parent;
int32 sibling;
if (m_nodes[node2].child1 == leaf)
{
sibling = m_nodes[node2].child2;
}
else
{
sibling = m_nodes[node2].child1;
}
if (node1 != b2_nullNode)
{
// Destroy node2 and connect node1 to sibling.
if (m_nodes[node1].child1 == node2)
{
m_nodes[node1].child1 = sibling;
}
else
{
m_nodes[node1].child2 = sibling;
}
m_nodes[sibling].parent = node1;
FreeNode(node2);
// Adjust ancestor bounds.
while (node1 != b2_nullNode)
{
b2AABB oldAABB = m_nodes[node1].aabb;
m_nodes[node1].aabb.Combine(m_nodes[m_nodes[node1].child1].aabb, m_nodes[m_nodes[node1].child2].aabb);
if (oldAABB.Contains(m_nodes[node1].aabb))
{
break;
}
node1 = m_nodes[node1].parent;
}
}
else
{
m_root = sibling;
m_nodes[sibling].parent = b2_nullNode;
FreeNode(node2);
}
}
示例12: power_tech_xml_load_multiplexer_info
/**
* Read multiplexer information from the .xml transistor characteristics.
* This contains the estimates of mux output voltages, depending on 1) Mux Size 2) Mux Vin
* */
static void power_tech_xml_load_multiplexer_info(ezxml_t parent) {
ezxml_t child, prev, gc;
int num_mux_sizes;
int i, j;
/* Process all multiplexer sizes */
num_mux_sizes = CountChildren(parent, "multiplexer", 1);
/* Add entries for 0 and 1, for convenience, although
* they will never be used
*/
g_power_tech->max_mux_sl_size = 1 + num_mux_sizes;
g_power_tech->mux_voltage_inf = (t_power_mux_volt_inf*) my_calloc(
g_power_tech->max_mux_sl_size + 1, sizeof(t_power_mux_volt_inf));
child = FindFirstElement(parent, "multiplexer", TRUE);
i = 1;
while (child) {
int num_voltages;
assert(i == GetFloatProperty(child, "size", TRUE, 0));
/* For each mux size, process all of the Vin levels */
num_voltages = CountChildren(child, "voltages", 1);
g_power_tech->mux_voltage_inf[i].num_voltage_pairs = num_voltages;
g_power_tech->mux_voltage_inf[i].mux_voltage_pairs =
(t_power_mux_volt_pair*) my_calloc(num_voltages,
sizeof(t_power_mux_volt_pair));
gc = FindFirstElement(child, "voltages", TRUE);
j = 0;
while (gc) {
/* For each mux size, and Vin level, get the min/max V_out */
g_power_tech->mux_voltage_inf[i].mux_voltage_pairs[j].v_in =
GetFloatProperty(gc, "in", TRUE, 0.0);
g_power_tech->mux_voltage_inf[i].mux_voltage_pairs[j].v_out_min =
GetFloatProperty(gc, "out_min", TRUE, 0.0);
g_power_tech->mux_voltage_inf[i].mux_voltage_pairs[j].v_out_max =
GetFloatProperty(gc, "out_max", TRUE, 0.0);
prev = gc;
gc = gc->next;
FreeNode(prev);
j++;
}
prev = child;
child = child->next;
FreeNode(prev);
i++;
}
}
示例13: while
void palProfiler::FreeNode(palProfilerNode* node) {
if (node->child) {
palProfilerNode* sibling_node = node->child->sibling;
while (sibling_node != NULL) {
palProfilerNode* next = sibling_node->sibling;
FreeNode(sibling_node);
sibling_node = next;
}
FreeNode(node->child);
}
if (node != &root_) {
_profile_proxy_allocator->Destruct(node);
}
}
示例14: MkSubst
void MkSubst( NODE *n1, NODE *n2 )
{
NODE *n;
n = LookUpSubst( n1 );
if( n == 0 ) {
n = n1;
n->left = substList;
substList = n;
} else {
FreeNode( n->right );
FreeNode( n1 );
}
n->right = n2;
}
示例15: Sub
NODE * Sub( NODE *n1, NODE *n2 )
{
if( n1 == 0 ) return BinaryOp( SUB, 0, n2 );
if( n2 == 0 ) return n1;
if( IsConst( n1, 0 ) ) {
FreeNode( n1 );
return BinaryOp( SUB, 0, n2 );
}
if( IsConst( n2, 0 ) ) {
FreeNode( n2 );
return n1;
}
return BinaryOp( SUB, n1, n2 );
}