As an example of the way these methods may be utilized, consider the definition of a WPAbstract subclass, Stack, with the Push() and Pop() methods. The following sample code fragments show the Push() and Pop() methods using the memory allocation methods. Push() allocates space for the new item, initializes its contents and places it on the stack while Pop() removes the top item from the stack, and returns its contents. The stack is implemented as a linked list of entries with the head of the list being the top of the stack. Assume the existence of methods, Lock() and Unlock(), which protect the stack linked list in a multithread environment.

Note: The sample code fragments in this section are part of a complete program that provides a new object class, Stack, whose instances implement standard programming push down stacks. The program is illustrated in "Sample Code for Setup/Cleanup Methods".