void del(CGELptr &g) { map<CGELptr,void *>::iterator it; it = _dhash.find(g); if (it != _dhash.end()) { del_item(it->second); _dhash.erase(it); } }
void *tc_list_pop(TCList *L, int pos) { TCListItem *IT = find_position(L, pos); void *data = NULL; if (IT) { data = IT->data; if (L->head == IT) { if (IT->next) { IT->next->prev = NULL; } L->head = IT->next; } else if (L->tail == IT) { if (IT->prev) { IT->prev->next = NULL; } L->tail = IT->prev; } else { IT->next->prev = IT->prev; IT->prev->next = IT->next; } del_item(L, IT); L->nelems--; } return data; }
int main() { int a; do{ printf("Press 1 for Adding Item to list\n"); printf("Press 2 for Deleting Item from list\n"); printf("Press 3 to Display list\n"); printf("press 4 to Exit \n"); scanf("%d",&a); switch(a){ case 1:{add_item(); break;} case 2:{del_item(); break;} case 3:{display(); break;} case 4:{exit_end(); break;} default:{printf("Sorry I Can't Understand you !\n"); break;} } printf("\n"); }while(a!=4); return 0; }
static void parser_reset(Parser *parser) { if (parser->currItem) { del_item(&parser->currItem->head); parser->currItem = 0; } parser->lineState = STATE_PREFIX; }
int main() { int usrip; struct lnlst *head; head = (struct lnlst *)malloc(sizeof(struct lnlst)); head->data = 0; head->next = NULL; while (1) { printf("1. Add\n"); printf("2. Delete\n"); printf("3. Traverse\n"); printf("4. Show All\n"); printf("5. Delete All\n"); printf("6. Exit\n"); printf("Please enter an option\n"); scanf("%d", &usrip); switch (usrip) { case 1: add_item(head); break; case 2: del_item(head); break; case 3: traverse(head); break; case 4: show_all(head); break; case 5: del_all(head); break; case 6: del_all(head); printf ("\nExiting...\n"); return 0; default: del_all(head); printf ("Hey Ass****! can you not see a list of options provided\n"); printf ("Get lost... Exiting...\n"); return 0; } } return 0; }
/** * Maneja los semáforos y obtiene un item del buffer * cuando el proceso entra en la sección crítica **/ void consume(int id_proc, int times, tpBuffer pBuffer, int semId){ int i; for (i = 0; i < times; ++i) { P(semId, SEM_LLENO); P(semId, SEM_MUTEX); del_item(id_proc, pBuffer); // Sección crítica V(semId, SEM_MUTEX); V(semId, SEM_VACIO); } }
void ClearFolder(Folder *pFolder) { Item *item = pFolder->items; while (item) { Item* next = item->next; del_item(item, MODE_FOLDER == pFolder->mode); item = next; } pFolder->items = NULL; if (pFolder->id_notify) { remove_change_notify_entry(pFolder->id_notify); pFolder->id_notify = 0; } delete_pidl_list(&pFolder->pidl_list); }
struct item *main_menu(struct item *ptr) { /* Menu for user`s choice */ int choice = 0; for(;;) { printf("1.Initialize list of items\n"); printf("2.Add item in existing list\n"); printf("3.Delete item with specified name\n"); printf("4.Output list on monitor\n"); printf("5.Exit\n"); choice = getchar(); clear_buffer(); if(choice >= '1' && choice <= '4') { switch(choice) { case '1' : ptr = add_item(ptr, 0); break; case '2' : ptr = add_item(ptr, 1); break; case '3' : ptr = del_item(ptr); break; case '4' : out_list(ptr); break; } } else if(choice == '5') { break; } else { printf("Wrong choice. Please input again\n"); } } if(ptr != NULL) { while(ptr->prev != NULL) { ptr = ptr->prev; } } return ptr; }
// ---------------------------------------------- Item *join_folders(Item *items) { items = Sort(items); Item *mi = items, *mn; if (mi) while (NULL != (mn = mi->next)) { // compare first with second if (mi->m_pszTitle[0] && 0 == _stricmp(mi->m_pszTitle, mn->m_pszTitle)) { // set list ptr to the 3rd item, which becomes the second now mi->next = mn->next; // delete the second menu item del_item(mn, true); } else { // the second is now the first mi = mn; } } return items; }
void _delvec(QSP_ARG_DECL Data_Obj *dp) { assert(dp!=NULL); assert(OBJ_NAME(dp)!=NULL); #ifdef ZOMBIE_SUPPORT // This should go back in eventually! if( OBJ_FLAGS(dp) & DT_STATIC && OWNS_DATA(dp) ){ sprintf(ERROR_STRING,"delvec: static object %s will be made a zombie",OBJ_NAME(dp)); advise(ERROR_STRING); make_zombie(dp); return; } if( OBJ_REFCOUNT(dp) > 0 ){ /* This zombie business was introduced at a time * when a displayed image had to be kept around * to refresh its window... with the current * X windows implementation of viewers that is * no longer the case, so this may be unecessary... * * But another case arises when we have a static * object in the expression language, that gets * deleted outside of the expression language. * This shouldn't be done, but we don't want to * be able to crash the program either... */ sprintf(ERROR_STRING,"delvec: object %s (refcount = %d) will be made a zombie",OBJ_NAME(dp),dp->dt_refcount); advise(ERROR_STRING); make_zombie(dp); return; } #endif /* ZOMBIE_SUPPORT */ // If the object has been exported, we need to delete // the associated identifier... // // BUT if it was exported, then it may be referenced!? // So it should be static... // // If we have references, and are therefore keeping the // object as a zombie, then we don't want to delete the // identifier, and we probably don't want to change the // object's name... if( IS_EXPORTED(dp) ){ Identifier *idp; idp = id_of(OBJ_NAME(dp)); assert( idp != NULL ); delete_id((Item *)idp); } if( OBJ_CHILDREN( dp ) != NULL ){ delete_subobjects(dp); } if( OBJ_PARENT(dp) != NULL ){ disown_child(dp); } if( IS_TEMP(dp) ){ if( OBJ_DECLFILE(dp) != NULL ){ sprintf(ERROR_STRING,"delvec %s: temp object has declfile %s!?\n", OBJ_NAME(dp),OBJ_DECLFILE(dp)); advise(ERROR_STRING); } release_tmp_obj(dp); /* * Most likely called when parent is deleted. * Temp objects are not hashed, and are not dynamically * allocated. * * Simply mark as free by clearing name field. */ return; } // We might clean this up by making the release // function a platform member... if( OWNS_DATA(dp) ){ if( ! UNKNOWN_SHAPE(OBJ_SHAPE(dp)) ){ release_data(dp); } } // In the first OpenCL implementation, we used subbuffers, which had // to be released here even for subimages. But now we handle subobjects // ourselves, managing offsets, so non-data-owners don't need to release. rls_shape( OBJ_SHAPE(dp) ); // We don't need to do this if we have garbage collection? /* The name might be null if we had an error creating the object... */ if( OBJ_DECLFILE(dp) != NULL ){ rls_str( OBJ_DECLFILE(dp) ); } #ifdef ZOMBIE_SUPPORT /* BUG context code assumes that this is really deleted... */ // not sure I understand the above comment? if( IS_ZOMBIE(dp) ){ // The object is a zombie that is no longer referenced... /* NOTE: we used to release the struct here with givbuf, * but in the current implementation of the item package, * objects aren't allocated with getbuf! */ // The object has already been removed from the dictionary, // so we don't need to call del_item... /* put this back on the free list... */ recycle_item(dobj_itp,dp); } else { del_item(dobj_itp, dp ); } #else /* ! ZOMBIE_SUPPORT */ DELETE_OBJ_ITEM(dp); // del_dobj - item function #endif /* ! ZOMBIE_SUPPORT */ // used to release the name here // and set to null, but that is done in del_item }
void del_hash_items() { map<CGELptr,void *>::iterator it; for (it = _dhash.begin(); it != _dhash.end(); ++it) del_item(it->second); _dhash.clear(); }
void basic_sim::drop_item(basic_item& toDrop) { toDrop.on_drop(*this); //and remove the item del_item(toDrop); }