void check_patients_assess_par(struct Village *village) 
{
	struct Patient *list = village->hosp.assess;
	float rand;
	struct Patient *p;

	//printf("check_patients\n");
	while (list != NULL) 
	{
		printf("check in patients\n");
		p = list;
		list = list->forward; 
		p->time_left--;

		if (p->time_left == 0) 
		{ 
			rand = my_rand(&(p->seed));
			/* sim_covalescense_p % */
			if (rand < sim_convalescence_p)
			{
				rand = my_rand(&(p->seed));
				/* !sim_realloc_p % or root hospital */
				printf("rand(%f) > sim_relloc_p(%f) || vl(%d) = sl(%d)\n", 
						rand, 
						sim_realloc_p, 
						village->level, 
						sim_level);
				if (rand > sim_realloc_p || village->level == sim_level) 
				{
					printf("here\n");
					removeList(&(village->hosp.assess), p);
					addList(&(village->hosp.inside), p);
					p->time_left = sim_convalescence_time;
					p->time += p->time_left;
				}
				else /* move to upper level hospital !!! */
				{
					village->hosp.free_personnel++;
					removeList(&(village->hosp.assess), p);
					omp_set_lock(&(village->hosp.realloc_lock));
					//hpx_lco_sema_p(village->hosp.mutex);
					//hpx_lco_sema_p(mutex);
					printf("In critical region.\n");
					addList(&(village->back->hosp.realloc), p); 
					//hpx_lco_sema_v_sync(mutex);
					//hpx_lco_sema_v_sync(village->hosp.mutex);
					omp_unset_lock(&(village->hosp.realloc_lock));
				} 
			}
			else /* move to village */
			{
				village->hosp.free_personnel++;
				removeList(&(village->hosp.assess), p);
				addList(&(village->population), p); 
			}
		}
	} 
}
void
LogBuffer::deleteHandlers()
{
   removeList(m_handlersDebug);
   removeList(m_handlersInfo);
   removeList(m_handlersWarn);
   removeList(m_handlersError);
   removeList(m_handlersFatal);
}
Beispiel #3
0
// the cleanup function
void removeList(Value *list) {
    if (list->type == CONS_TYPE) {
        removeList(list->c.cdr);
        removeList(list->c.car);
    } else if (list->type == PTR_TYPE) {
        free(list->p);
    }
    free(list);
}
Beispiel #4
0
int main(int argc, char* argv[]) {
    int returned = -1;
    struct linkedList* q = createLinkedList(3);
    printf("Checking if the list is empty: %d\n", isEmptyList(q));
    
    printf("Attempting to add to front \n");
    addFrontList(q, 1);
    removeList(q, 1);
    printf("Checking if the list is empty: %d\n", isEmptyList(q));
    addFrontList(q, 2);
    addFrontList(q, 3);
    _printList(q);
    
    printf("Attempting to add to back \n");
    addBackList(q, 4);
    addBackList(q, 5);
    addBackList(q, 6);
    _printList(q);
    
    printf("Attempting to print front \n");
    printf("%d\n", frontList(q));
    
    printf("Attempting to print back \n");
    printf("%d\n", backList(q));
    
    printf("Attempting to remove front \n");
    removeFrontList(q);
    _printList(q);
    
    printf("Attempting to remove back \n");
    removeBackList(q);
    _printList(q);
    
    printf("Attempting to delete 4 \n");
    removeList(q, 4);
    _printList(q);
    
    printf("Attempting to print list \n");
    _printList(q);
    
    printf("Attempting to confirm contains 5 \n");
    returned = containsList(q, 5);
    if (returned == 1)
        printf("true \n");
    else
        printf("false \n");
    
    return 0;
}
static char *test_removeList() {
    Node *head = (Node *) malloc(sizeof(Node));
    head->next = (Node *) malloc(sizeof(Node));
    head = removeList(head);
    mu_assert("Error in test_removeList", head == NULL);
    return 0;
}
static char *test_removeElementFromList_lastElement() {
    Person *testPerson1 = (Person *) malloc(sizeof(Person));
    Person *testPerson2 = (Person *) malloc(sizeof(Person));
    Person *testPerson3 = (Person *) malloc(sizeof(Person));

    testPerson1->first_name = "Zbigniew";
    testPerson1->last_name = "Ostatek";

    testPerson2->first_name = "Wladimir";
    testPerson2->last_name = "Srodkowy";

    testPerson3->first_name = "Andrzej";
    testPerson3->last_name = "Pierwszy";

    Node *testListHead = initList(testPerson1);
    testListHead = pushFront(testListHead, testPerson2);
    testListHead = pushFront(testListHead, testPerson3);

    Node *secondNode = testListHead->next;

    Node *nodeToRemove = (Node *) malloc(sizeof(Node));
    Person *removePerson = (Person *) malloc(sizeof(Person));
    removePerson->first_name = "Zbigniew";
    removePerson->last_name = "Ostatek";
    nodeToRemove->person = removePerson;
    nodeToRemove->previous = secondNode;

    Node *listAfterRemoval = removeElementFromList(testListHead, nodeToRemove);
    mu_assert("error in testRemoveElementFromList_lastElement",
              listAfterRemoval->next->next == NULL);
    removeList(listAfterRemoval);
    free(nodeToRemove);
    free(removePerson);
    return 0;
}
PrivacyDlg::PrivacyDlg(JabberAccount* acc, QWidget* parent) : KDialog(parent), acc_(acc)
{
	QWidget * w = new QWidget (this);
	ui_.setupUi(w);
	setMainWidget (w);
	setAttribute(Qt::WA_DeleteOnClose);
	setCaption(i18n("%1: Privacy Lists", (acc->myself()->nickName() ) ) );
	setButtons (KDialog::Close);
	ui_.lv_rules->setFocus (Qt::PopupFocusReason);

	PrivacyManager* manager = acc->client()->privacyManager();
	connect(manager,SIGNAL(listsReceived(QString,QString,QStringList)),SLOT(updateLists(QString,QString,QStringList)));
	connect(manager,SIGNAL(listReceived(PrivacyList)),SLOT(refreshList(PrivacyList)));
	connect(manager,SIGNAL(listError()),SLOT(list_failed()));
	//connect(manager,SIGNAL(listNamesError()),SLOT(listNamesError()));
	//connect(manager,SIGNAL(listReceiveError()),SLOT(listReceiveError()));

	connect(ui_.cb_active,SIGNAL(activated(int)),SLOT(active_selected(int)));
	connect(ui_.cb_default,SIGNAL(activated(int)),SLOT(default_selected(int)));
	connect(ui_.cb_lists,SIGNAL(activated(int)),SLOT(list_selected(int)));
	connect(ui_.cb_lists,SIGNAL(currentIndexChanged(int)),SLOT(list_changed(int)));
	connect(manager,SIGNAL(changeActiveList_success()),SLOT(change_succeeded()));
	connect(manager,SIGNAL(changeActiveList_error()),SLOT(change_failed()));
	connect(manager,SIGNAL(changeDefaultList_success()),SLOT(change_succeeded()));
	connect(manager,SIGNAL(changeDefaultList_error()),SLOT(change_failed()));
	connect(manager,SIGNAL(changeList_success()),SLOT(changeList_succeeded()));
	connect(manager,SIGNAL(changeList_error()),SLOT(changeList_failed()));

	connect(ui_.pb_newList,SIGNAL(clicked()),SLOT(newList()));
	connect(ui_.pb_deleteList,SIGNAL(clicked()),SLOT(removeList()));
	
	connect(ui_.pb_add,SIGNAL(clicked()),SLOT(addRule()));
	connect(ui_.pb_edit,SIGNAL(clicked()),SLOT(editCurrentRule()));
	connect(ui_.pb_remove,SIGNAL(clicked()),SLOT(removeCurrentRule()));
	connect(ui_.pb_up,SIGNAL(clicked()),SLOT(moveCurrentRuleUp()));
	connect(ui_.pb_down,SIGNAL(clicked()),SLOT(moveCurrentRuleDown()));
	connect(ui_.pb_apply,SIGNAL(clicked()),SLOT(applyList()));
	
	ui_.pb_newList->setIcon(KIcon("list-add"));
	ui_.pb_deleteList->setIcon(KIcon("list-remove"));
	ui_.pb_add->setIcon(KIcon("list-add"));
	ui_.pb_remove->setIcon(KIcon("list-remove"));
	ui_.pb_up->setIcon(KIcon("arrow-up"));
	ui_.pb_down->setIcon(KIcon("arrow-down"));
	ui_.pb_edit->setIcon(KIcon("edit-rename"));
	ui_.pb_apply->setIcon(KIcon("dialog-ok-apply"));

	setWidgetsEnabled(false);

	// Disable all buttons
	ui_.pb_deleteList->setEnabled(false);
	setEditRuleEnabled(false);
	ui_.pb_add->setEnabled(false);
	ui_.pb_apply->setEnabled(false);

	// FIXME: Temporarily disabling auto-activate
	ui_.ck_autoActivate->hide();
	
	manager->requestListNames();
}
static char *test_removeElementFromList_firstElement() {
    Person *testPerson1 = (Person *) malloc(sizeof(Person));
    testPerson1->first_name = "John";
    testPerson1->last_name = "Kowalsky";
    Person *testPerson2 = (Person *) malloc(sizeof(Person));
    testPerson2->first_name = "Wladimir";
    testPerson2->last_name = "Nowak";

    Node *testListHead = initList(testPerson1);
    testListHead = pushFront(testListHead, testPerson2);

    Node *secondNode = testListHead->next;

    Person *removePerson = (Person *) malloc(sizeof(Person));
    removePerson->first_name = "Wladimir";
    removePerson->last_name = "Nowak";
    Node *nodeToRemove = (Node *) malloc(sizeof(Node));
    nodeToRemove->person = removePerson;
    nodeToRemove->previous = NULL;
    nodeToRemove->next = secondNode;

    Node *listAfterRemoval = removeElementFromList(testListHead, nodeToRemove);
    mu_assert("error in removeElementFromList_firstElement",
              strcmp(listAfterRemoval->person->first_name ,"John") == 0);
    removeList(listAfterRemoval);
    free(removePerson);
    return 0;
}
void DoubleLinkedList::removeElement(int position)
{
    node *tmp;
    tmp = head;
    int num=0;
    if(!ListIsEmpty() && position >= 0)
    {
        while(num<position){
            if(tmp->next != NULL){
                tmp=tmp->next;
                num++;
            }else break;
        }
        if(tmp->next == NULL && tmp->prev == NULL)removeList();
        else if(tmp->next != NULL)
        {
            if(tmp->prev !=NULL)
            {
                tmp->prev->next=tmp->next;
                tmp->next->prev=tmp->prev;
            }
            else{
                head = tmp->next;
                head->prev = NULL;
            }
        }
        else {
            tail = tmp->prev;
            tail->next = NULL;
        }
        delete tmp;
    }
}
void showMenu()
{
 int choose=0;
 do
 {
  printf("\n");
  printf("1. add element at ends of list\n");
  printf("2. add element at start of list\n");
  printf("3. add element at middle of list\n");
  printf("4. remove element from starts of list\n");
  printf("5. remove element from middle of list\n");
  printf("6. remove element from ends of list\n");
  printf("7. create list\n");
  printf("8. remove list\n");
  printf("9. exit\n");
  scanf("%i", &choose);
  switch (choose)
  {
   case 1: addLastElement();break;
   case 2: addFirstElement();break;
   case 3: addMiddleElement();break;
   case 4: removeFirstElement();break;
   case 5: removeMiddleElement();break;
   case 6: removeLastElement();break;
   case 7: createList();break;
   case 8: removeList();
  }
 }
 while(choose!=9);
}
Beispiel #11
0
bool ListBoxDnd::mouseMoveEvent( QMouseEvent * event )
{
    if ( event->state() & LeftButton ) {
	if ( ( event->pos() - mousePressPos ).manhattanLength() > 3 ) {

	    ListBoxItemList list;
	    buildList( list );
	    ListBoxItemDrag * dragobject = new ListBoxItemDrag( list, (dMode & Internal), (QListBox *) src );

	    // Emit signal for all dragged items
	    QListBoxItem * i = list.first();
	    while ( i ) {
		emit dragged( i );
		i = list.next();
	    }

	    if ( dMode & Move ) {
		removeList( list ); // "hide" items
	    }

	    dragobject->dragCopy();

	    if ( dMode & Move ) {
		if ( dropConfirmed ) {
		    // ###FIX: memleak ? in internal mode, only pointers are transfered...
		    //list.setAutoDelete( TRUE );
		    list.clear();
		    dropConfirmed = FALSE;
		}
		insertList( list ); // "show" items
	    }
	}
    }
    return FALSE;
}
Beispiel #12
0
int main(int argc, char* argv[]) {
        struct linkedList *b;
        int n, i;
        double t1, t2;

        for(n=1000; n < 200000; n=n*2) /* outer loop */
        {

			b = createLinkedList();

			for( i = 0 ; i < n; i++) {
					addList(b, (TYPE)i); /*Add elements*/
			}

			t1 = getMilliseconds();/*Time before contains()*/

			for(i=0; i<n; i++) {
					removeList(b, i);
			}

			t2 = getMilliseconds();/*Time after contains()*/

			printf("Time for running contains() on %d elements: %g ms\n", n, t2-t1);

			/* delete DynArr */
			deleteLinkedList(b);
        }
        return 0;
}
static char *test_initList_existingPersonEmptyEmail() {
    Person *testPerson = (Person *) malloc(sizeof(Person));
    Node *testListHead = initList(testPerson);
    mu_assert("error in initList_existingPersonEmptyEmail", testListHead->person->email == 0);
    removeList(testListHead);
    return 0;
}
static char *test_findElement_ElementDoesNotExist() {
    Person *testPerson = (Person *) malloc(sizeof(Person));
    Person *testPerson2 = (Person *) malloc(sizeof(Person));
    Person *testPerson3 = (Person *) malloc(sizeof(Person));

    Person *elementToFind = (Person *) malloc(sizeof(Person));
    testPerson->first_name = "Abdel";
    testPerson->last_name = "Akacja";
    testPerson2->first_name = "Boguslaw";
    testPerson2->last_name = "Bluszcz";
    testPerson3->first_name = "Cezary";
    testPerson3->last_name = "Czomber";

    elementToFind->first_name = "Dionizy";
    elementToFind->last_name = "Dab";

    Node *list = initList(testPerson);
    list = pushFront(list, testPerson2);
    list = pushFront(list, testPerson3);

    mu_assert("error in findElement_ElementDoesNotExist", findElement(list, elementToFind) == 0);
    removeList(list);
    free(elementToFind);
    return 0;
}
Beispiel #15
0
void Creature::onRemovedCreature()
{
	setRemoved();
	removeList();
	if(master && !master->isRemoved())
		master->removeSummon(this);
}
Beispiel #16
0
void check_patients_assess_par(struct Village *village) 
{
   struct Patient *list = village->hosp.assess;
   float rand;
   struct Patient *p;

   while (list != NULL) 
   {
      p = list;
      list = list->forward; 
      p->time_left--;

      if (p->time_left == 0) 
      { 
         rand = my_rand(&(p->seed));
         /* sim_covalescense_p % */
         if (rand < sim_convalescence_p)
         {
            rand = my_rand(&(p->seed));
            /* !sim_realloc_p % or root hospital */
            if (rand > sim_realloc_p || village->level == sim_level) 
            {
               removeList(&(village->hosp.assess), p);
               addList(&(village->hosp.inside), p);
               p->time_left = sim_convalescence_time;
               p->time += p->time_left;
            }
            else /* move to upper level hospital !!! */
            {
               village->hosp.free_personnel++;
               removeList(&(village->hosp.assess), p);
               int err = pthread_mutex_lock(&(village->hosp.realloc_lock));
               assert(err == 0);
               addList(&(village->back->hosp.realloc), p); 
               err = pthread_mutex_unlock(&(village->hosp.realloc_lock));
               assert(err == 0);
            } 
         }
         else /* move to village */
         {
            village->hosp.free_personnel++;
            removeList(&(village->hosp.assess), p);
            addList(&(village->population), p); 
         }
      }
   } 
}
static char *test_initList_existingPersonLastName() {
    Person *testPerson = (Person *) malloc(sizeof(Person));
    testPerson->last_name = "Kowalsky";
    Node *testListHead = initList(testPerson);
    mu_assert("error in initList_existingPersonLastName",
              strcmp(testListHead->person->last_name, "Kowalsky") == 0);
    removeList(testListHead);
    return 0;
}
int main(){
   List l1;createList(&l1);
   char s[1024];s[0] = '\0';
   
   int i;
   for(i = 0;i < 12;i++){   
      insert(createNode(i*100),i,&l1);
      showList(&l1);
   }
   
   Node *n = removeList(3,&l1);
   showList(&l1);
   printf("3 removed: %d\n\n",n->entry.a);
   
   n->entry.a += 150;
   insert(n,9,&l1);
   showList(&l1);
   printf("9 inserted: %d\n\n",n->entry.a);
   
   showList(&l1);
   printf("%d found at pos %d\n\n",n->entry.a,search(n,&l1));
   
   n = createNode(101);
   showList(&l1);
   printf("%d not found pos != %d\n\n",n->entry.a,search(n,&l1));
   
   showList(&l1);
   printf("3 has: %d\n\n",search_k(3,&l1)->entry.a);
   
   for(i = 0;i < 12;i++){
      char s[1024];
      
      if(!empty(&l1)){
         n = removeList(1,&l1);
         if(n != NULL)
            free(n);
      }else
         printf("Empty list...\n");
      showList(&l1);
   }
   
   gets(s);
   return 0;
}
Beispiel #19
0
void Creature::onRemoved()
{
	removeList();
	setRemoved();

	if(getMaster() && !getMaster()->isRemoved()){
		getMaster()->removeSummon(this);
	}

}
Beispiel #20
0
/**
 * memory cleaning, printing the game result
 * parameter - was the game finished correctly or not
 */
void endGame(int correct) { 
	removeList(globalUnitsList);
	if (correct) {
		if (kingOne == kingTwo) gameWinner = 0;
		else if (kingOne > kingTwo) {
			gameWinner = 1;
		 }
		else {
			gameWinner = 2;
		}
	}
}
static char *test_pushFront_newPersonToEmptyList() {
    Person *testPerson = (Person *) malloc(sizeof(Person));
    testPerson->first_name = "John";
    testPerson->last_name = "Kowalsky";
    testPerson->address = "Walbrzych";
    Node *testListHead = pushFront(NULL, testPerson);

    mu_assert("error in pushFront_newPersonToEmptyList",
              strcmp(testListHead->person->first_name, "John") == 0 );
    removeList(testListHead);
    return 0;
}
Beispiel #22
0
void RecoveryByL2::delVerThreeSeparateRelation()
{
    if(verThreeSeparateRelation){
        for(int i = 0;i < (int)meshmodel->numtriangles;i++){
            if(NULL != verThreeSeparateRelation[i]){
                removeList(verThreeSeparateRelation[i]);
            }
            verThreeSeparateRelation[i] = NULL;
        }
        delete []verThreeSeparateRelation;
        verThreeSeparateRelation = NULL;
    }
}
//!-----------------------------------
void processList()
{
    header_t Head = {};
    initiateList(&Head);

    insert_in(1, 2, RIGHT, &Head);
    insert_in(2, 3, RIGHT, &Head);
    insert_in(3, 4, RIGHT, &Head);
    insert_in(4, 5, RIGHT, &Head);
    insert_in(4, 5, LEFT, &Head);
    remove_in(2, LEFT, &Head);
    remove_in(2, RIGHT, &Head);
    removeList(&Head);
}
int main()
{
	CList *head = new CList;
	head->value = 0;
	head->next = NULL;
	printf("Counting - for every round of a cyclic list remove the k-th element, while not in the list will be only one. Enter the length of the list and number of the last element. Will be calculated the numbers of k before n!. \n\nn = ");
	int n = 0;
	scanf("%i", &n);
	printf("\nlast = ");
	int last = 0;
	scanf("%i", &last);
	
	long nFact = 1;
	for (int i = 1; i <= n; i++)
			nFact = nFact * i;

	List *lhead = new List;
	lhead->next = NULL;
	
	for (int k = 1; k <= nFact; k++)
	{
		fill(head, n);
		CList *tmp = head;
		while (lengh(head) != 1)
		{
			for (int c = 1; c < k; c++)
			{
				tmp = tmp->next;
			}
			del(head, returnNum(head, tmp->next));
		}
		if (tmp->next->value == last)
			ladd(lhead, k, 1000);
		del(head, 1);
	}

	printf("\n\nk = {");
	lprintList(lhead);
	printf("}\n");
	
	removeList(head);
	lremoveList(lhead);
	
	scanf("%*");

	delete lhead;	
	delete head;
	return 0;
}
Beispiel #25
0
PrivacyDlg::PrivacyDlg(const QString& account_name, PrivacyManager* manager, QWidget* parent) : QDialog(parent), manager_(manager)
{
	ui_.setupUi(this);
	setAttribute(Qt::WA_DeleteOnClose);
	setWindowTitle(tr("%1: Privacy Lists").arg(account_name));
	setWindowFlags(Qt::Dialog | Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint | Qt::CustomizeWindowHint);

	connect(manager_,SIGNAL(listsReceived(const QString&, const QString&, const QStringList&)),SLOT(updateLists(const QString&, const QString&, const QStringList&)));
	connect(manager_,SIGNAL(listReceived(const PrivacyList&)),SLOT(refreshList(const PrivacyList&)));
	connect(manager_,SIGNAL(listError()),SLOT(list_failed()));
	//connect(manager_,SIGNAL(listNamesError()),SLOT(listNamesError()));
	//connect(manager_,SIGNAL(listReceiveError()),SLOT(listReceiveError()));

	connect(ui_.cb_active,SIGNAL(activated(int)),SLOT(active_selected(int)));
	connect(ui_.cb_default,SIGNAL(activated(int)),SLOT(default_selected(int)));
	connect(ui_.cb_lists,SIGNAL(activated(int)),SLOT(list_selected(int)));
	connect(ui_.cb_lists,SIGNAL(currentIndexChanged(int)),SLOT(list_changed(int)));
	connect(manager_,SIGNAL(changeActiveList_success(QString)),SLOT(changeActiveList_succeeded(QString)));
	connect(manager_,SIGNAL(changeActiveList_error()),SLOT(change_failed()));
	connect(manager_,SIGNAL(changeDefaultList_success(QString)),SLOT(changeDefaultList_succeeded(QString)));
	connect(manager_,SIGNAL(changeDefaultList_error()),SLOT(change_failed()));
	connect(manager_,SIGNAL(changeList_success(QString)),SLOT(changeList_succeeded(QString)));
	connect(manager_,SIGNAL(changeList_error()),SLOT(changeList_failed()));

	connect(ui_.pb_newList,SIGNAL(clicked()),SLOT(newList()));
	connect(ui_.pb_deleteList,SIGNAL(clicked()),SLOT(removeList()));
	connect(ui_.pb_renameList,SIGNAL(clicked()),SLOT(renameList()));

	connect(ui_.pb_add,SIGNAL(clicked()),SLOT(addRule()));
	connect(ui_.pb_edit,SIGNAL(clicked()),SLOT(editCurrentRule()));
	connect(ui_.pb_remove,SIGNAL(clicked()),SLOT(removeCurrentRule()));
	connect(ui_.pb_up,SIGNAL(clicked()),SLOT(moveCurrentRuleUp()));
	connect(ui_.pb_down,SIGNAL(clicked()),SLOT(moveCurrentRuleDown()));
	connect(ui_.pb_apply,SIGNAL(clicked()),SLOT(applyList()));

	connect(ui_.buttonBox->button(QDialogButtonBox::Close),SIGNAL(clicked()),SLOT(close()));
	setWidgetsEnabled(false);

	// Disable all buttons
	ui_.pb_deleteList->setEnabled(false);
	setEditRuleEnabled(false);
	ui_.pb_add->setEnabled(false);
	ui_.pb_apply->setEnabled(false);

	// FIXME: Temporarily disabling auto-activate
	ui_.ck_autoActivate->hide();

	manager_->requestListNames();
}
/**
 * Cria números aleatóriamente
 * @param l elemento do tipo t_lista
 * @param n número de interações
 */
void createTest(t_lista *l, int n)
{
    int i, v[n];

    for (i = 0; i <= n; i++) v[i] = rand() % 2;

    for (i = 0; i < n; i++) printf("%d", v[i]);

    printf("\n");

    for (i = 0; i < n; i++) if (v[i] == 1) {
        insertList(l);
    } else {
        if (! isEmptyList(l)) removeList(l);
    }
}
void check_patients_realloc(struct Village *village)
{
	struct Patient *p, *s;

	while (village->hosp.realloc != NULL) 
	{
		p = s = village->hosp.realloc;
		while (p != NULL)
		{
			if (p->id < s->id) s = p;
			p = p->forward;
		}
		removeList(&(village->hosp.realloc), s);
		put_in_hosp(&(village->hosp), s);
	}
}
void check_patients_inside(struct Village *village) 
{
	struct Patient *list = village->hosp.inside;
	struct Patient *p;

	while (list != NULL)
	{
		p = list;
		list = list->forward; 
		p->time_left--;
		if (p->time_left == 0) 
		{
			village->hosp.free_personnel++;
			removeList(&(village->hosp.inside), p); 
			addList(&(village->population), p); 
		}    
	}
}
Beispiel #29
0
void free_usb_device(UsbDevice * udev)
{
	List * listHook;
#ifdef __KERNEL__
	destroy_workqueue(udev->workqueue);
#endif
	while ( udev->endpoints_handles != NULL )
	{
		listHook = popFront(&udev->endpoints_handles);
		remove_endpoint_handle((EndpointHandle*)listHook->data);
		FREE(listHook);
	}

	removeList(&udev->detached_interfaces);

	FREE(udev->ctrl0_buf);
	FREE(udev);
}
static char *test_pushFront_newPersonToExisitingListPointersTests() {
    Person *testPerson = (Person *) malloc(sizeof(Person));
    testPerson->first_name = "John";
    testPerson->last_name = "Kowalsky";
    testPerson->address = "Walbrzych";
    Node *testListHead = initList(testPerson);

    Person *testPerson2 = (Person *) malloc(sizeof(Person));
    testPerson2->first_name = "Wladimir";
    testPerson2->last_name = "Nowak";
    testPerson2->address = "Wroclaw";

    testListHead = pushFront(testListHead, testPerson2);
    mu_assert("error in pushFront_newPersonToExistingListPointersTests",
              testListHead == testListHead->next->previous);
    removeList(testListHead);
    return 0;
}