5.1.1 New

Because a struct _Stack contains a pointer to a struct List, we do need to allocate storage for a struct _Stack object:

struct Stack *Stack_new(void)
{
  struct _Stack *tmp;
  tmp = (struct _Stack *)malloc(sizeof(struct _Stack));
  tmp->pList = List_new();
  return (struct Stack *)tmp;
}



Copyright © 2006-10-23 by Tak Auyeung