void compile(Node *n) /* called from parser only */ { extern long autooffset; Errjmp x; n=constants(n); if(cflag){ fprint(2, "%z:constants:\n"); dump(n, 0); } errsave(x); if(errmark()){ autooffset=0; resultloc=0; breakloc=-1; continueloc=-1; didbecome=0; freenode(n); errrest(x); errjmp(); } istart(); gen(n, 0); freenode(n); errrest(x); }
static void freenode(struct segtabnode *n) { if (!n) return; freenode(n->left); freenode(n->right); nasm_free(n); }
/* * Funzione di supporto per la cancellazione. */ void freenode(hpnode_t* hpn) { if(hpn != 0) { freenode(hpn->sup); freenode(hpn->inf); free(hpn); } }
/** * Unloads dictionary from memory. Returns true if successful else false. */ bool unload(void) { node* current = root; freenode(current); return true; }
/* Note: only updates the in-memory copy, which is written out at mydbm_close time. Note: Also differs from DBM in that on duplication, it gives a warning, rather than either DBM_INSERT or DBM_REPLACE behavior. */ int mydbm_store (DBM *db, datum key, datum value, int flags) { Node *node; node = getnode (); node->type = NDBMNODE; node->key = xmalloc (key.dsize + 1); *node->key = '\0'; strncat (node->key, key.dptr, key.dsize); node->data = xmalloc (value.dsize + 1); *(char *)node->data = '\0'; strncat (node->data, value.dptr, value.dsize); db->modified = 1; if (addnode (db->dbm_list, node) == -1) { error (0, 0, "attempt to insert duplicate key `%s'", node->key); freenode (node); return 0; } return 0; }
void freelightsource(void *n) { struct lightsource *ls = n; struct node *nlse; int w, c; long overflow; if (ls->fl) { delflickeringlight(ls); } for (nlse = ls->effects.head->next; nlse != NULL; nlse = nlse->next) { for (w = 0; w < 6; w++) { if (nlse->prev->d.lse->cube->d.c->walls[w]) { for (c = 0; c < 4; c++) { overflow = nlse->prev->d.lse->cube->d.c->walls[w]->corners[c]. light - nlse->prev->d.lse->add_light[w * 4 + c]; nlse->prev->d.lse->cube->d.c->walls[w]->corners[c].light = overflow < view.illum_minvalue ? view.illum_minvalue : overflow; } } } freenode(&ls->effects, nlse->prev, free); } FREE(ls); }
struct pathnode * strtopath(char *pathstr) { struct pathnode *root; struct pathnode *p; char *w; char *aux; initpath(root); for (p = root; p != NULL; p = p->next) { my_strtok(pathstr,aux,w); p->next = NULL; while (w != NULL && !(strcmp(".",w) && strcmp("..",w)) ) { if (strcmp("..",w) == 0) { p = p->prev; if (p->next != NULL) freenode(p->next); } free(w); my_strtok(pathstr,aux,w); } if (w != NULL) { p->next = palloc(); (p->next)->name = w; (p->next)->prev = p; } } return root; }
/*The method deletes the last node of the list * and sets the prev pointer to null, if the last on the list * and the set every pointer to null */ void deleteLast(ListHndl L) { NodePtr tmp = NULL; if(L == NULL) { printf("Error: List has not been created.\n"); exit(1); } if(isEmpty(L)) { printf("Error: Can't delete nothing contained in the list.\n"); exit(1); } tmp = L->first; if(L->size >1) { L->last = L->last->prev; L->last->next = NULL; } else { L->first = NULL; L->current = NULL; L->last = NULL; } L->size--; freenode(&tmp); }
static int Delete(lua_State *L) { unsigned int i; scene_t *scene = testscene(L, 1); if(!scene) return 0; /* already deleted */ /* first, release all userdata */ #define Free(what, freefunc) do { \ if(scene->mNum##what > 0) \ { \ for(i=0; i < scene->mNum##what; i++) \ freefunc(L, scene->m##what[i]); \ } \ } while(0) Free(Meshes, freemesh); Free(Materials, freematerial); Free(Lights, freelight); Free(Textures, freetexture); Free(Cameras, freecamera); Free(Animations, freeanimation); #undef Free if(scene->mRootNode) freenode(L, scene->mRootNode); TRACE_DELETE(scene, "scene"); freeuserdata(L, scene); /* finally, release the scene */ aiReleaseImport(scene); return 0; }
int main() { clink head = NULL; //循环链表指针 clink memory = NULL; //内存管理指针 clink ptr; int list[6] = {1,2,3,4,5,6}; //数组内容 int i; //用循环创建内存链表,总共7个结点 for(i = 0; i < 7; i++) { //分配一个结点内存 ptr = (clink)malloc(sizeof(cnode)); if(!ptr) //检查内存指针 { exit(1); } ptr->next = NULL; ptr->data = 100 + i; //创建结点内存 freenode(&memory,ptr); //释放一个结点内存 } printmemory(memory); //输出内存链表 head = createclist(list,&memory,6); //创建循环链表 printclist(head); //输出循环链表 //循环链表的内存释放 freeclist(head,&memory); printmemory(memory); //输出内存链表 return 0; }
static void gnr_node__hash_timeout(void) { int idx; time_t now; now = time(NULL); for (idx = 0; idx < GNR_NODE_HASH_SIZE; idx++) { struct gnrnode *cur, **prev; for (prev = &gnr__nodehash[idx]; (cur = *prev); ) { if (cur->metric == GNR_NODE_METRIC_LOCAL) { /* local nodes never time out */ prev = &cur->next; continue; } if ((cur->ttl == -1) || (cur->refcount > 0) || ((now - cur->lastuse) < cur->ttl)) { prev = &cur->next; continue; } *prev = cur->next; freenode(cur, GNR_NODE_OFFLINE_REASON_TIMEOUT); } } return; }
void vlc_tdestroy (void *root, void (*freenode) (void *)) { const void **tab; size_t count; assert (freenode != NULL); /* Enumerate nodes in order */ vlc_mutex_lock (&list.lock); assert (list.count == 0); twalk (root, list_nodes); tab = list.tab; count = list.count; list.tab = NULL; list.count = 0; vlc_mutex_unlock (&list.lock); /* Destroy the tree */ vlc_mutex_lock (&smallest.lock); for (size_t i = 0; i < count; i++) { smallest.node = tab[i]; if (tdelete (smallest.node, &root, cmp_smallest) == NULL) abort (); } vlc_mutex_unlock (&smallest.lock); assert (root == NULL); /* Destroy the nodes */ for (size_t i = 0; i < count; i++) freenode ((void *)(tab[i])); free (tab); }
static awk_bool_t api_set_argument(awk_ext_id_t id, size_t count, awk_array_t new_array) { #ifdef DYNAMIC NODE *arg; NODE *array = (NODE *) new_array; (void) id; if (array == NULL || array->type != Node_var_array) return false; if ( (arg = get_argument(count)) == NULL || arg->type != Node_var_new) return false; arg = get_array_argument(count, false); if (arg == NULL) return false; array->vname = arg->vname; *arg = *array; freenode(array); return true; #else return false; #endif }
int mfree(PCB *currentPCB, void *ptr){ int address; int size; uint32 virtual_address,physical_address; if(ptr==NULL){ return -1; } if(((int)ptr<16384)||((int)ptr>=20480)){ //out of range return -1; } address=((int)ptr)-16384; virtual_address=ptr; physical_address=MemoryTranslateUserToSystem(currentPCB,virtual_address); // printf("free address is %d\n",address); if(((size=freenode(address,currentPCB->heapnode)))!=-1){ printf("Freeing heap block of size <%d> bytes: virtual address <0x%x> , physical address <0x%x>\n",size,virtual_address,physical_address); freetree(currentPCB->heapnode); return(size); } else{ printf("Cannot free the heap block of size<%d> bytes:virtual address <0x%x>, physicsal address <0x%x>\n",size, virtual_address,physical_address); return NULL; } }
void finalcleanup ( void ) { /* 10 */ smallnumber c ; c = curmod ; if ( jobname == 0 ) openlogfile () ; while ( inputptr > 0 ) if ( ( curinput .indexfield > 15 ) ) endtokenlist () ; else endfilereading () ; while ( loopptr != 0 ) stopiteration () ; while ( openparens > 0 ) { print ( 1078 ) ; decr ( openparens ) ; } while ( condptr != 0 ) { printnl ( 1079 ) ; printcmdmod ( 2 , curif ) ; if ( ifline != 0 ) { print ( 1080 ) ; printint ( ifline ) ; } print ( 1081 ) ; ifline = mem [condptr + 1 ].cint ; curif = mem [condptr ].hhfield .b1 ; loopptr = condptr ; condptr = mem [condptr ].hhfield .v.RH ; freenode ( loopptr , 2 ) ; } if ( history != 0 ) { if ( ( ( history == 1 ) || ( interaction < 3 ) ) ) { if ( selector == 3 ) { selector = 1 ; printnl ( 1082 ) ; selector = 3 ; } } } if ( c == 1 ) { ; #ifdef INIMF if ( iniversion ) { storebasefile () ; goto lab10 ; } #endif /* INIMF */ printnl ( 1083 ) ; goto lab10 ; } lab10: ; }
int removesS(struct pqueue *q) { int temp; int temp2=q->front; temp = l[q->front].info; q->front = l[q->front].next; freenode(temp2); return temp; }
float popsfloat() { LINK *x; float tempfloat; tempfloat = list->info.c; x = list->next; freenode(list); list = x; return tempfloat; }
char popschar() { LINK *x; char tempchar; tempchar = list->info.b; x = list->next; freenode(list); list = x; return tempchar; }
int popsint() { int tempint; LINK *x; tempint = list->info.a; x = list->next; freenode(list); list = x; return tempint; }
void dlist_trim_to_limit( struct dlistnode** list, int limit, dlist_visitor_func_type f ) { int sz = dlist_size( list ); while( sz >= limit ) { struct dlistnode* node = dlist_popback( list ); f(node); freenode(node); sz = dlist_size( list ); } }
int gnr_node_offline(struct gnrnode *gn, int reason) { if (gnr_node__hash_remove(gn) != gn) return -1; /* uhm. */ freenode(gn, reason); return 0; }
int pops() { int temp; LINK *x; temp = list->info; if(list->right!=NULL) { x = list->right; freenode(list); list = x; x->left = NULL; } else { freenode(list); list = NULL; } return temp; }
int pops() { int temp; LINK *x; temp = list->info; x = list->next; freenode(list); list = x; return temp; }
static DefNode *freenode(DefNode *pdn) { if (pdn) { //fprintf(stderr, "free %s.\n", pdn->def); pdn->next = freenode(pdn->next); free(pdn->def); free(pdn->val); free(pdn); } return pdn = 0; }
int deleteaftr(LINK *y) { LINK *x; int temp; x = y->next; y->next = x->next; temp = x->info; freenode(x); return temp; }
char deleteaftrchar(LINK *y) { LINK *x; char tempchar; x = y->next; y->next = x->next; tempchar = x->info.b; freenode(x); return tempchar; }
int deletes(LINK *y) { int temp; (y->left)->right = y->right; (y->right)->left = y->left; temp = y->info; freenode(y); list->info = count; return temp; }
int deleteaftrint(LINK *y) { LINK *x; int tempint; x = y->next; y->next = x->next; tempint = x->info.a; freenode(x); return tempint; }
void freelist( struct list *l, void (*freeentry)(void *) ) { struct node *n; for (n = l->head->next; n != NULL; n = n->next) { freenode(l, n->prev, freeentry); } l->size = 0; initlist(l); }
float deleteaftrfloat(LINK *y) { LINK *x; float tempfloat; x = y->next; y->next = x->next; tempfloat = x->info.c; freenode(x); return tempfloat; }