本文整理汇总了C++中freeNode函数的典型用法代码示例。如果您正苦于以下问题:C++ freeNode函数的具体用法?C++ freeNode怎么用?C++ freeNode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了freeNode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: freeNode
void freeNode(NODE *node) {
// release Name-Values (attribs)
nameValue *nextNV = NULL;
while (node->nV) {
nextNV = node->nV->next;
if (node->nV->bFreeValuePtr) {
free(node->nV->value.s);
}
free(node->nV);
node->nV = nextNV;
}
// release child
if (node->child) {
freeNode(node->child);
}
// release brother
if (node->next) {
freeNode(node->next);
}
free(node);
}
示例2: deleteLast
void deleteLast(ListRef L) {
NodeRef n;
if (L == NULL) {
printf( "Error: Called deleteLast() on NULL ListRef\n");
//exit(EXIT_FAILURE);
} else if (isEmpty(L)) {
printf( "Error: Called deleteLast() on empty ListRef\n");
//exit(EXIT_FAILURE);
}
if ( L->first == L->current ) {
L->current = NULL;
}
if (L->length == 1) {
freeNode(&(L->last));
L->last = NULL;
L->first = NULL;
} else {
n = L->last;
L->last = n->prev;
n->prev->next = NULL;
n->prev = NULL;
freeNode(&n);
n = NULL;
}
L->length--;
}
示例3: deleteNodeAt
void deleteNodeAt(int i)
{
if (i == 0) {
// Removing head
Node *tmp = head;
head = head->next;
tmp->next = NULL;
freeNode(tmp);
} else {
int j = 0;
Node *node = head;
Node *prev = NULL;
while (j < i) {
prev = node;
node = node->next;
j++;
}
prev->next = node->next;
node->next = NULL;
freeNode(node);
}
size--;
}
示例4: freeList
/**
* This method is the deconstructor for the List class
*/
void freeList(ListPtr list) {
if (list == NULL ) {
return;
}
if (list->size == 0) {
free(list);
return;
}
if (list->size == 1 && list->head != NULL ) {
freeNode(list->head, list->freeObject);
free(list);
return;
}
if (list->size < 0 || (list->head != NULL && list->head->data == NULL) || (list->tail!= NULL && list->tail->data == NULL))
return;
NodePtr temp = list->head;
while (temp->next != NULL ) {
NodePtr tempPrev = temp;
temp = temp->next;
freeNode(tempPrev, list->freeObject);
}
freeNode(temp, list->freeObject);
free(list);
return;
}
示例5: assignNode
bTreeNode bTree::findBro(bTreeNode& node){
bTreeNode par = assignNode(node.parentPtr);
if(findPath.back() > 0 && findPath.back() < par.valNum)
{
bTreeNode l = assignNode(par.ptrList[findPath.back()-1]);
bTreeNode r = assignNode(par.ptrList[findPath.back()+1]);
freeNode(par);
if(l.valNum<r.valNum)
{
freeNode(r);
return l;
}
else
{
freeNode(l);
return r;
}
}
freeNode(par);
if(findPath.back() > 0)
return assignNode(par.ptrList[findPath.back()-1]);
if(findPath.back() < par.valNum)
return assignNode(par.ptrList[findPath.back()+1]);
return bTreeNode();
}
示例6: taskwdAnyRemove
void taskwdAnyRemove(void *key)
{
struct mNode *pm;
struct aNode *pa;
taskwdInit();
epicsMutexMustLock(mLock);
pm = (struct mNode *)ellFirst(&mList);
while (pm) {
if (pm->funcs == &anyFuncs) {
pa = (struct aNode *)pm->usr;
if (pa->key == key) {
ellDelete(&mList, (void *)pm);
freeNode((union twdNode *)pa);
freeNode((union twdNode *)pm);
epicsMutexUnlock(mLock);
return;
}
}
pm = (struct mNode *)ellNext(&pm->node);
}
epicsMutexUnlock(mLock);
errlogPrintf("taskwdAnyRemove: Unregistered key %p\n", key);
}
示例7: convertAttributesToText
Node convertAttributesToText (Node node)
{
char* str;
int len, at, i;
Node ret = 0, examine = node->firstChild, prevExamine;
AttributeData ad;
if (node->type != AttributeGroup) return 0;
/* We've stored the first child in examine, so we can already free the parent */
freeNode (node);
while (examine) /* should be an Attribute node */
{
ad = examine->data.attrdata;
/* first turn attribute name, equals sign (if any) and
* opening apostrophe or quotes (if any) into one string */
len = strlen (ad->name);
at = len;
len += ad->spacesAfterName;
if (ad->type > 0)
{
len++; /* '=' */
len += ad->spacesAfterEquals;
if (ad->type > 1) len++; /* ' or " */
}
len++; /* trailing '\0' */
str = (char*) malloc (len * sizeof (char));
memcpy (str, ad->name, at * sizeof (char));
while (ad->spacesAfterName--) str[at++] = ' ';
if (ad->type > 0)
{
str[at++] = '=';
while (ad->spacesAfterEquals--) str[at++] = ' ';
if (ad->type == 2) str[at++] = '\'';
else if (ad->type == 3) str[at++] = '"';
}
str[at] = '\0';
ret = makeTextBlock2 (ret, newNodeS (TextToken, str), examine->firstChild);
if (ad->type > 1 || (ad->type == 1 && ad->spacesAfterValue > 0))
{
at = ad->type > 1 ? 1 : 0;
len = at + ad->spacesAfterValue;
str = (char*) malloc (len * sizeof (char));
if (ad->type == 2) str[0] = '\'';
else if (ad->type == 3) str[0] = '"';
while (ad->spacesAfterValue--) str[at++] = ' ';
str[at] = '\0';
ret = makeTextBlock (ret, newNodeS (TextToken, str));
}
prevExamine = examine;
examine = examine->nextSibling;
freeNode (prevExamine);
}
return ret;
}
示例8: recDelete
int recDelete(rect *r, node *n, int pos){
int i,j;
node *n1, *n2;
if(n->leaf){
for(i = 0; i < n->size; ++i)
if(n->values[i]->child == pos){
deleteValue(n, i);
writeNode(n);
return TRUE;
}
return FALSE;
}
for(i = 0; i < n->size; ++i)
if(intersect(r, n->values[i]->r)){
n1 = readNode(n->values[i]->child);
if(recDelete(r, n1, pos)){
n->values[i]->r = dupRect(n1->MBR);
if(n1->size < b )
underflow(n, n1, i);
else{
refreshMBR(n);
writeNode(n);
freeNode(n1);
}
return TRUE;
}
else
freeNode(n1);
}
return FALSE;
}
示例9: removeFromList
void removeFromList(Node** head, int offset) {
//int location = findOffset(head, offset);
printf("\n removing from list ");
Node* p = *head;
int i =0;
if((*head)->data->offset == offset)
{
*head = (*head)->next;
freeNode(p);
return;
}
while(p->next!=NULL) {
if(p->next->data->offset == offset)
break;
p = p->next;
}
printf("\n printing value of prev node%d", p->data->offset);
Node* q = p->next;
if(p->next!=NULL)
p->next = p->next->next;
freeNode(q);
printf("\n removed node");
}
示例10: findFirstNode
std::vector<unsigned int> bTree::findGreater(Index ind, bool equal){
unsigned int i;
std::vector<unsigned int> res;
bTreeNode cur = findFirstNode(ind);
for (i = 0; i < cur.valNum; ++i)
{
if(cur.indexList[i]>=ind)
break;
}
if(i>=cur.valNum)
{
freeNode(cur);
if(cur.ptrList.back()==0)
return res;
cur = assignNode(cur.ptrList.back());
i = 0;
}
while(true)
{
if(equal || cur.indexList[i]!=ind)
res.push_back(cur.ptrList[i]);
i++;
if(i>=cur.valNum)
{
if(cur.ptrList[i]==0)
break;
freeNode(cur);
cur = assignNode(cur.ptrList[i]);
i = 0;
}
}
freeNode(cur);
return res;
}
示例11: freeList
void freeList(ListPtr L) {
NodePtr tempNode, currentNode;
if (L==NULL){
return;
}
if (L->head == NULL ) {
free(L);
return;
}
if (L->head == L->tail) {
freeNode(L->head, (void *) L->freeObject);
free(L);
return;
}
currentNode = L->head;
while (currentNode != NULL ) {
tempNode = currentNode;
currentNode = currentNode->next;
freeNode(tempNode, (void *) L->freeObject);
}
free(L);
}
示例12: freeNode
/* Recursively deallocate the memory assigned to this node's subtree */
void freeNode(priorityQueueEntry* node)
{
if(node->childl)
freeNode(node->childl);
if(node->childr)
freeNode(node->childr);
free(node);
}
示例13: freeNode
void freeNode( Node *node )
{
if (node != NULL) {
freeNode( node->left );
freeNode( node->right );
}
free( node );
}
示例14: freeNode
/* freeNode: free node created with node() */
void freeNode(struct node *node)
{
if (node == NULL)
return;
freeNode(node->child);
freeNode(node->next);
}
示例15: freeNode
/*!
\internal
*/
void QGeneralAreaAllocator::freeNode(Node *node)
{
if (node) {
freeNode(node->left);
freeNode(node->right);
}
delete node;
}