#ifndef MEMNODES_H
#define MEMNODES_H
#include "nodes/nodes.h"
typedef struct MemoryContextCounters
{
Size nblocks;
Size freechunks;
Size totalspace;
Size freespace;
} MemoryContextCounters;
typedef void (*MemoryStatsPrintFunc) (MemoryContext context, void *passthru,
const char *stats_string,
bool print_to_stderr);
typedef struct MemoryContextMethods
{
void *(*alloc) (MemoryContext context, Size size, int flags);
void (*free_p) (void *pointer);
void *(*realloc) (void *pointer, Size size, int flags);
void (*reset) (MemoryContext context);
void (*delete_context) (MemoryContext context);
MemoryContext (*get_chunk_context) (void *pointer);
Size (*get_chunk_space) (void *pointer);
bool (*is_empty) (MemoryContext context);
void (*stats) (MemoryContext context,
MemoryStatsPrintFunc printfunc, void *passthru,
MemoryContextCounters *totals,
bool print_to_stderr);
#ifdef MEMORY_CONTEXT_CHECKING
void (*check) (MemoryContext context);
#endif
} MemoryContextMethods;
typedef struct MemoryContextData
{
pg_node_attr(abstract)
NodeTag type;
bool isReset;
bool allowInCritSection;
Size mem_allocated;
const MemoryContextMethods *methods;
MemoryContext parent;
MemoryContext firstchild;
MemoryContext prevchild;
MemoryContext nextchild;
const char *name;
const char *ident;
MemoryContextCallback *reset_cbs;
} MemoryContextData;
#define MemoryContextIsValid(context) \
((context) != NULL && \
(IsA((context), AllocSetContext) || \
IsA((context), SlabContext) || \
IsA((context), GenerationContext) || \
IsA((context), BumpContext)))
#endif