當前位置: 首頁>>代碼示例>>C++>>正文


C++ FreeNode函數代碼示例

本文整理匯總了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;
}
開發者ID:fanqingsong,項目名稱:code-snippet,代碼行數:31,代碼來源:tagContentParsing.c

示例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);
}
開發者ID:gap-packages,項目名稱:nq,代碼行數:10,代碼來源:presentation.c

示例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 );                                  
}
開發者ID:CEKrause,項目名稱:WRFV_3.7.1,代碼行數:26,代碼來源:code.c

示例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;
}
開發者ID:Annie2333,項目名稱:DS_Code,代碼行數:35,代碼來源:link_list2.cpp

示例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 );
}
開發者ID:CEKrause,項目名稱:WRFV_3.7.1,代碼行數:25,代碼來源:code.c

示例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;
	}
開發者ID:azunite,項目名稱:duiengine,代碼行數:31,代碼來源:stree.hpp

示例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);
}
開發者ID:TianLanhe,項目名稱:Data_Structure,代碼行數:33,代碼來源:Polynomail.c

示例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;
}
開發者ID:JukkaL,項目名稱:alore,代碼行數:61,代碼來源:std_hashvalue.c

示例9: FreeNode

void FreeNode( NODE * n )
{
  if( n == 0 ) return;
  FreeNode( n->left );
  FreeNode( n->right );
  if( n->elm ) free( n->elm );
  free( n );
}
開發者ID:CEKrause,項目名稱:WRFV_3.7.1,代碼行數:8,代碼來源:code.c

示例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();
}
開發者ID:1vanK,項目名稱:AHRUnrealEngine,代碼行數:58,代碼來源:b2DynamicTree.cpp

示例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);
	}
}
開發者ID:006,項目名稱:ios_lab,代碼行數:55,代碼來源:b2DynamicTree.cpp

示例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++;
	}
}
開發者ID:haojunliu,項目名稱:OpenFPGA,代碼行數:57,代碼來源:power_cmos_tech.c

示例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);
  }
}
開發者ID:astrotycoon,項目名稱:pal,代碼行數:14,代碼來源:pal_profiler.cpp

示例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;
}
開發者ID:CEKrause,項目名稱:WRFV_3.7.1,代碼行數:15,代碼來源:code.c

示例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 );                                  
}
開發者ID:CEKrause,項目名稱:WRFV_3.7.1,代碼行數:15,代碼來源:code.c


注:本文中的FreeNode函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。