// myPathStack.cpp: implementation of the myPathStack class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "myExplorer.h" #include "myPathStack.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// myPathStack::myPathStack() { head = (PPATHNODE)malloc(sizeof(PATHNODE)); memset(head,0,sizeof(PATHNODE)); head->next = NULL; } myPathStack::~myPathStack() { free(head); head = NULL; } PPATHNODE myPathStack::Push(HTREEITEM item) { if(item == head->hItem) return NULL; PPATHNODE temp = NULL; temp = (PPATHNODE)malloc(sizeof(PATHNODE)); if(temp == NULL) return NULL; temp->hItem = item; temp->next = head->next; head->next = temp; head->hItem = temp->hItem; return temp; } PPATHNODE myPathStack::Pop() { if(head->next == NULL) return NULL; PPATHNODE temp; temp = head->next; head->next = temp->next; head->hItem = temp->hItem; free(temp); return head; }