4.3.5 Set first value

Setting the first value of a list involves the following logic:

The implementation is as follows:

void List_setfirstvalue(struct List *pList, char v)
{
  if (!((struct _List *)pList)->first)
  {
    // we don't have a first node
    struct _Listnode *pNode;

    pNode = (struct _Listnode *)malloc(sizeof(struct _Listnode));
    pNode->rest.first = NULL;
    ((struct _List *)pList)->first = pNode;
  }
  ((struct _List *)pList)->first->firstvalue = v;
}



Copyright © 2006-09-27 by Tak Auyeung