Esempio n. 1
0
// *(preplace->w) < *(item->w)
int put_item (item_t *preplace, item_t **item, int *listlen) {
	item_t *vitem = *item;
	if ( *(preplace->p) >= *(vitem->p) ) {
		free_items (item);
		return 1;
	} else {
		/*if ( vitem->flag != TRUE_ELEM ) */vitem->flag = NEW_ELEM;
		item_t *pnext = preplace->next, *tmp;
		if ( pnext != NULL && /*pnext->flag != TRUE_ELEM && */*(pnext->w) == *(vitem->w) ) {
			if ( *(pnext->p) < *(vitem->p)  ) {
				preplace->next = vitem;
				if ( pnext->flag == OLD_ELEM || pnext->flag == ONESHOT_ELEM ) {
					//vitem->next = pnext->next;
					//pnext->next = vitem;
					//preplace->next = pnext;
					vitem->next = pnext;
					pnext->flag = ONESHOT_ELEM;
					(*listlen)++;
				} else {
					vitem->next = pnext->next;
					free_items (&pnext);
				}
				return 0;
			} else {
				free_items (item);
				return 1;
			}
		} else {
			preplace->next = vitem;
			vitem->next = pnext;
			(*listlen)++;
		}
	}
	return 0;
}
Esempio n. 2
0
void spice_marshaller_reset(SpiceMarshaller *m)
{
    SpiceMarshaller *m2, *next;
    SpiceMarshallerData *d;

    /* Only supported for root marshaller */
    assert(m->data->marshallers == m);

    for (m2 = m; m2 != NULL; m2 = next) {
        next = m2->next;
        free_item_data(m2);

        /* Free non-root marshallers */
        if (m2 != m) {
            free_items(m2);
            free(m2);
        }
    }

    m->next = NULL;
    m->n_items = 0;
    m->total_size = 0;

    d = m->data;
    d->last_marshaller = d->marshallers;
    d->total_size = 0;
    d->base = 0;
    d->current_buffer_item = NULL;
    d->current_buffer = d->buffers;
    d->current_buffer_position = 0;
}
Esempio n. 3
0
static void
free_pollers(rb_poller* poll)
{
    rb_poller* next;
    file_path* fp;
    for(; poll; poll = next)
    {
        free_items(poll->items);

        next = poll->next;

        /* Free the associated file paths */
        while(poll->rrdlist) {
            fp = poll->rrdlist->next;
            free(poll->rrdlist);
            poll->rrdlist = fp;
        }

        while(poll->rawlist) {
            fp = poll->rawlist->next;
            free(poll->rawlist);
            poll->rawlist = fp;
        }

        free(poll);
    }

}
Esempio n. 4
0
void free_task(task_t **p){
  if ( p ) {
    if( (*p)->items != NULL ) free_items ( &((*p)->items) );
    free (*p);
    *p = NULL;
  }
}
Esempio n. 5
0
// find preplace and cut bad items with inefficient payoffs
item_t* find_preplace_badcutter (item_t *list, knint *itemw, int *listlen) {
	if ( *(list->w) >= *itemw ) return NULL;
	knint edge = *(list->p);
	item_t *tmp;
	do {
		// remove inefficient elems after item "list"
		while ( list->next != NULL && edge >= *(list->next->p) ) {
			if ( list->next->flag == NEW_ELEM ) {
				tmp = list->next;
				list->next = list->next->next;
				free_items (&tmp);
				(*listlen)--;
			} else {
				if ( list->next->flag == OLD_ELEM ) {
					list->next->flag = ONESHOT_ELEM;
				}
				break;//list = list->next;
			}
		}// while

		if ( list->next != NULL && *(list->next->w) < *itemw ) {
			list = list->next;
			edge = *(list->p);
		// while we can step further
		} else break;
	} while ( 1 );
	return list;
}
Esempio n. 6
0
int update_menu_search(MENU_SEARCH *menu,CLIENT_OBJECT *cli,DB_OBJECT *db,SCREEN_OBJECT *scr)
{
    if (menu->items)
        free_items(menu);
    fetch_items(menu,scr->sta->search_buf,cli,db);

    return 0;
}
Esempio n. 7
0
void free_items_list (item_t **list){
  if ( list ) {
    item_t *p, *tmp;
    for ( p = *list ; p != NULL ; ) {
      tmp = p->next;
      free_items (&p);
      p = tmp;
    }
    *list = NULL;
  }
}
Esempio n. 8
0
void buybottle( void)
{
int &junk = free_items();


if (&junk < 1)
 {
         choice_start()
        set_y 240
        title_start();
You are carrying too much.
        title_end();
         "Ok"
         choice_end()
 return;
 }
Esempio n. 9
0
void spice_marshaller_destroy(SpiceMarshaller *m)
{
    MarshallerBuffer *buf, *next;
    SpiceMarshallerData *d;

    /* Only supported for root marshaller */
    assert(m->data->marshallers == m);

    spice_marshaller_reset(m);

    free_items(m);

    d = m->data;

    buf = d->buffers->next;
    while (buf != NULL) {
        next = buf->next;
        free(buf);
        buf = next;
    }

    free(d);
}
Esempio n. 10
0
// using when simple move elements from one node to another
int put_item_simple (item_t *preplace, item_t **item, int *listlen) {
	item_t *vitem = *item;
	if ( *(preplace->p) >= *(vitem->p) ) {
		return 1;
	} else {
		/*if ( vitem->flag != TRUE_ELEM ) */vitem->flag = NEW_ELEM;
		item_t *pnext = preplace->next, *tmp;
		if ( pnext != NULL && /*pnext->flag != TRUE_ELEM && */*(pnext->w) == *(vitem->w) ) {
			if ( *(pnext->p) < *(vitem->p)  ) {
				preplace->next = vitem;
				vitem->next = pnext->next;
				free_items (&pnext);				
				return 0;
			} else {
				return 1;
			}
		} else {
			preplace->next = vitem;
			vitem->next = pnext;
			(*listlen)++;
		}
	}
	return 0;
}
Esempio n. 11
0
int del_menu_search(MENU_SEARCH *menu)
{
    free_items(menu);
    free(menu);
    return 0;
}