You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

35 lines
450 B

#include "node.hpp"
#include <cstddef>
#include <cstdlib>
struct stack_t
{
stack_t *next;
};
thread_local static stack_t *g_stack = NULL;
node_t*
node_alloc()
{
if(g_stack == NULL)
return (node_t*)calloc(1,sizeof(node_t));
node_t *node;
node = (node_t*)g_stack;
g_stack = g_stack->next;
return node;
}
void
node_free(node_t *node_)
{
stack_t *stack;
stack = (stack_t*)node_;
stack->next = g_stack;
g_stack = stack;
}