// Copyright (c) 2001-2002 TiVo Inc.
//
// Author: Andy Goodman 

#ifdef __KERNEL__
#include <asm/linkq.h>
#else
#include "linkq.h"
#endif

bool LinkqIsEmpty(LinkqT *me)
{
  return me->ins == 0;
}

void
LinkqInit(LinkqT *me)
{
  me->ins = 0;
}

void
LinkqInsert(LinkqT *me,LinkItemT *item)
{
  if (me->ins == 0){
    me->ins = me->del = item;
  }else{
    me->ins->next = item;
    me->ins = item;
  }
  item->next = 0;
}

LinkItemT *
LinkqRemove(LinkqT *me)
{
  LinkItemT *res = 0;
  if (me->ins == 0) {
    goto cleanup;
  }
  if (me->del == me->ins) {
    me->ins = 0;
  }
  res = me->del;
  me->del = res->next;
    
 cleanup:
  return res;
}








