IStack.c
资源名称:MenuList.rar [点击查看]
上传用户:duwei1288
上传日期:2009-12-27
资源大小:451k
文件大小:1k
源码类别:
BREW编程
开发平台:
Visual C++
- #include "IStack.h"
- IStack* ISTACK_CreateInstance()
- {
- return MALLOCREC(IStack);
- }
- boolean ISTACK_Release(IStack** pStack)
- {
- FREEIF(*pStack);
- return TRUE;
- }
- boolean ISTACK_PushOnStack(IStack* pStack,void* pStackElement)
- {
- if((MAX_STACK_SIZE==pStack->m_nTopPtr)||(!pStack)||(!pStackElement))
- return FALSE;
- pStack->m_pData[pStack->m_nTopPtr++]=pStackElement;
- DBGPRINTF("Push on Stack(Number=%d)",pStack->m_nTopPtr);
- return TRUE;
- }
- void* ISTACK_PopFromStack(IStack* pStack)
- {
- if(!pStack)
- return NULL;
- DBGPRINTF("Pop from Stack(Number=%d)",pStack->m_nTopPtr);
- if(pStack->m_nTopPtr>0)
- return pStack->m_pData[pStack->m_nTopPtr--];
- else
- return NULL;
- }
- void* ISTACK_GetTopElement(IStack* pStack)
- {
- if(!pStack)
- return NULL;
- if(pStack->m_nTopPtr>0)
- return pStack->m_pData[pStack->m_nTopPtr-1];
- else
- return NULL;
- }