Exemple #1
0
/* Removes the element. return the element->next */
dlist_iter_t DListRemove(dlist_iter_t element)
{
	dlist_iter_t ret = (assert(element), DListNext(element));
/*	ret = element->next;*/
	element->prev->next = DListNext(element);
	element->next->prev = DListPrev(element);
	
	free(element);
	
	return(ret);
}
Exemple #2
0
static DLIST * FindInsertPoint( OBJPTR original )
/***********************************************/

/* order the clipboard list so that higher level objects are added before
 * lower level ones
 */

  {
    int         priority;
    int         currpr;
    DLIST *     lst;
    DLIST *     prev;
    DLIST_ELT   elt;

    prev = NULL;
    GetPriority( original, &priority );
    for( lst = ClipBoard.objs; lst != NULL; lst = DListNext( lst ) ) {
        elt = DListElement( lst );
        GetPriority( elt.copy, &currpr );
        if( currpr < priority ) {
            break;
        }
        prev = lst;
    }
    return( prev );
  }
Exemple #3
0
/* Destroys a list. */
void DListDestroy(dlist_t *dlist)
{
	dlist_iter_t cur = DListBegin(dlist);
	dlist_iter_t end = DListEnd(dlist);
	
	/*dlist_iter_t last_ptr = DListEnd(dlist); dlist->tail.prev;*/
	dlist_iter_t tmp = NULL;
	
	if(DListIsEmpty(dlist))/* if empty list, free dlist struct only( nothing else to free) */
	{
		free(dlist);
		return;
	}
	
	while(!DListIsSameIter(cur, end))
	{
		tmp = cur;
		cur = DListNext(cur);
		free(tmp);
	}
	
/*	for(tmp = last_ptr->prev; (last_ptr) && (last_ptr != &dlist->head); tmp = tmp->prev)*/
/*	{*/
/*		free(last_ptr);*/
/*		last_ptr = tmp;*/
/*	}*/
	free(dlist);
}
Exemple #4
0
/*   DListForEach stops upon fp failure. DListForEach returns fp exit status. */
int DListForEach(dlist_iter_t begin, dlist_iter_t end, action_func fp, void *param)
{
	int status = -1;
	
	while( (!DListIsSameIter(begin, end)) && (status))
	{
		status = fp(DListGetData(begin), param);
		begin = DListNext(begin);
	}
	return(status);
}
Exemple #5
0
/* Returns the number of elements inside the list. */
size_t DListSize(const dlist_t *dlist)
{
	size_t count = 0;
	dlist_iter_t s = DListBegin(dlist); /* dlist->head.next;*/
	dlist_iter_t e = DListEnd(dlist);
	
	while(!DListIsSameIter(s, e))
	{
		++count;
		s = DListNext(s);
	}
	return(count);
}
Exemple #6
0
/*Returns an iterator to the element found or 'end' */
dlist_iter_t DListFind(dlist_iter_t begin, dlist_iter_t end, is_match_func fp, const void *seek)
{
	int status = 0;
	while(!DListIsSameIter(begin, end))
	{
		status = fp(DListGetData(begin), seek);
		if(status)
		{
			return(begin);
		}
		begin = DListNext(begin);
	}
	return(begin);
}
Exemple #7
0
extern void * NextClipList( DLIST * clist )
/*****************************************/

  {
    return( DListNext( clist ) );
  }