mergerfs/libfuse/lib/node.cpp

40 lines
539 B
C++
Raw Normal View History

#include "node.hpp"
2025-10-27 20:58:06 -05:00
#include <mutex>
2025-10-25 18:21:18 -05:00
#include <cstddef>
#include <cstdlib>
2025-10-25 18:21:18 -05:00
struct stack_t
{
2025-10-25 18:21:18 -05:00
stack_t *next;
};
2025-10-25 18:21:18 -05:00
thread_local static stack_t *g_stack = NULL;
2025-10-26 14:53:46 -05:00
thread_local bool gc = false;
2025-10-27 21:00:21 -05:00
thread_local bool g_initialized = false;
node_t*
node_alloc()
{
2025-10-25 18:21:18 -05:00
if(g_stack == NULL)
return (node_t*)calloc(1,sizeof(node_t));
2025-10-25 18:21:18 -05:00
node_t *node;
2025-10-25 18:21:18 -05:00
node = (node_t*)g_stack;
g_stack = g_stack->next;
return node;
}
void
2025-10-25 18:21:18 -05:00
node_free(node_t *node_)
{
2025-10-25 18:21:18 -05:00
stack_t *stack;
2025-10-25 18:21:18 -05:00
stack = (stack_t*)node_;
stack->next = g_stack;
g_stack = stack;
}