【发布时间】:2020-03-09 05:09:18
【问题描述】:
我的推送功能有问题。这是堆栈结构的简单推送功能,但大多数时候不起作用。它仅在调试时有效。 这是函数:
tError favoriteStack_push(tFavoriteStack *stack, tFavorite favorite) {
//assert(stack!=NULL);
tFavoriteStackNode* tmp;
//mem_allocation of new node
tmp=(tFavoriteStackNode*)malloc(sizeof(tmp));
if(tmp==NULL)
return ERR_MEMORY_ERROR;
//copying element to new node
tmp->e=favorite;
//pointing next to previous first element
tmp->next=stack->first;
//new node is the new first node
stack->first=tmp;
return OK;
}
我看不到错误。 我将不胜感激。
谢谢
【问题讨论】: