I have a problem with a push function. It's a simple push function for stack structure but most of the time doesn't work. It only works when debugging. This is the function:
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;
}
I can't see the mistake. I would appreciate some help.
Thanks
 
    