This section describes how the setup and cleanup methods relate to one another using sample code fragments.
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.
The stack is implemented as a linked list of entries with the head of the list being the top of the stack. The following code fragments shows the content of the stack elements and the stack instance data:
typedef struct _STACKENTRY { PSTACKENTRY pNext; BYTE ReserveZeros[8]; ULONG cbEntry; BYTE Entry[1]; } STACKENTRY *PSTACKENTRY; BOOL bInitialized; // Initialization flag PSTACKENTRY pStackTop; // Head of stack linked list HMTX hmtxStack; // Stack serialization semaphore