first is NULL
firstvalue of the new list node
first of the rest of the new list node to NULL
first point to the list node
first is not NULL
firstvalue of the list node pointed to by
first
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;
}