Eneboo - Documentación para desarrolladores
src/libpq/include/nodes/memnodes.h
Ir a la documentación de este archivo.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * memnodes.h
00004  *        POSTGRES memory context node definitions.
00005  *
00006  *
00007  * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
00008  * Portions Copyright (c) 1994, Regents of the University of California
00009  *
00010  * $PostgreSQL: pgsql/src/include/nodes/memnodes.h,v 1.30 2004/12/31 22:03:34 pgsql Exp $
00011  *
00012  *-------------------------------------------------------------------------
00013  */
00014 #ifndef MEMNODES_H
00015 #define MEMNODES_H
00016 
00017 #include "nodes/nodes.h"
00018 
00019 /*
00020  * MemoryContext
00021  *              A logical context in which memory allocations occur.
00022  *
00023  * MemoryContext itself is an abstract type that can have multiple
00024  * implementations, though for now we have only AllocSetContext.
00025  * The function pointers in MemoryContextMethods define one specific
00026  * implementation of MemoryContext --- they are a virtual function table
00027  * in C++ terms.
00028  *
00029  * Node types that are actual implementations of memory contexts must
00030  * begin with the same fields as MemoryContext.
00031  *
00032  * Note: for largely historical reasons, typedef MemoryContext is a pointer
00033  * to the context struct rather than the struct type itself.
00034  */
00035 
00036 typedef struct MemoryContextMethods
00037 {
00038         void       *(*alloc) (MemoryContext context, Size size);
00039         /* call this free_p in case someone #define's free() */
00040         void            (*free_p) (MemoryContext context, void *pointer);
00041         void       *(*realloc) (MemoryContext context, void *pointer, Size size);
00042         void            (*init) (MemoryContext context);
00043         void            (*reset) (MemoryContext context);
00044         void            (*delete) (MemoryContext context);
00045         Size            (*get_chunk_space) (MemoryContext context, void *pointer);
00046         bool            (*is_empty) (MemoryContext context);
00047         void            (*stats) (MemoryContext context);
00048 #ifdef MEMORY_CONTEXT_CHECKING
00049         void            (*check) (MemoryContext context);
00050 #endif
00051 } MemoryContextMethods;
00052 
00053 
00054 typedef struct MemoryContextData
00055 {
00056         NodeTag         type;                   /* identifies exact kind of context */
00057         MemoryContextMethods *methods;          /* virtual function table */
00058         MemoryContext parent;           /* NULL if no parent (toplevel context) */
00059         MemoryContext firstchild;       /* head of linked list of children */
00060         MemoryContext nextchild;        /* next child of same parent */
00061         char       *name;                       /* context name (just for debugging) */
00062 } MemoryContextData;
00063 
00064 /* utils/palloc.h contains typedef struct MemoryContextData *MemoryContext */
00065 
00066 
00067 /*
00068  * MemoryContextIsValid
00069  *              True iff memory context is valid.
00070  *
00071  * Add new context types to the set accepted by this macro.
00072  */
00073 #define MemoryContextIsValid(context) \
00074         ((context) != NULL && \
00075          (IsA((context), AllocSetContext)))
00076 
00077 #endif   /* MEMNODES_H */
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'