diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/nodes/memnodes.h | 10 | ||||
-rw-r--r-- | src/include/nodes/nodes.h | 7 | ||||
-rw-r--r-- | src/include/utils/memutils.h | 32 | ||||
-rw-r--r-- | src/include/utils/palloc.h | 26 | ||||
-rw-r--r-- | src/include/utils/portal.h | 6 |
5 files changed, 65 insertions, 16 deletions
diff --git a/src/include/nodes/memnodes.h b/src/include/nodes/memnodes.h index accf6ed131d..4be4fe42620 100644 --- a/src/include/nodes/memnodes.h +++ b/src/include/nodes/memnodes.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: memnodes.h,v 1.8 1998/09/01 04:36:39 momjian Exp $ + * $Id: memnodes.h,v 1.9 1999/02/06 16:50:30 wieck Exp $ * * XXX the typedefs in this file are different from the other ???nodes.h; * they are pointers to structures instead of the structures themselves. @@ -56,7 +56,7 @@ typedef struct MemoryContextMethodsData void (*dump) (); } *MemoryContextMethods; -typedef struct MemoryContext +typedef struct MemoryContextData { NodeTag type; MemoryContextMethods method; @@ -64,7 +64,7 @@ typedef struct MemoryContext /* think about doing this right some time but we'll have explicit fields for now -ay 10/94 */ -typedef struct GlobalMemory +typedef struct GlobalMemoryData { NodeTag type; MemoryContextMethods method; @@ -75,14 +75,14 @@ typedef struct GlobalMemory typedef MemoryContext *PortalMemoryContext; -typedef struct PortalVariableMemory +typedef struct PortalVariableMemoryData { NodeTag type; MemoryContextMethods method; AllocSetData setData; } *PortalVariableMemory; -typedef struct PortalHeapMemory +typedef struct PortalHeapMemoryData { NodeTag type; MemoryContextMethods method; diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h index d001c33c991..2635f1d7603 100644 --- a/src/include/nodes/nodes.h +++ b/src/include/nodes/nodes.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nodes.h,v 1.38 1999/02/04 03:19:10 momjian Exp $ + * $Id: nodes.h,v 1.39 1999/02/06 16:50:31 wieck Exp $ * *------------------------------------------------------------------------- */ @@ -283,6 +283,11 @@ extern void *stringToNode(char *str); extern void *copyObject(void *obj); /* + * nodes/freefuncs.c + */ +extern void freeObject(void *obj); + +/* * nodes/equalfuncs.c */ extern bool equal(void *a, void *b); diff --git a/src/include/utils/memutils.h b/src/include/utils/memutils.h index 9e1adb796f6..0bf4f6ef13b 100644 --- a/src/include/utils/memutils.h +++ b/src/include/utils/memutils.h @@ -15,7 +15,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: memutils.h,v 1.19 1998/12/26 18:15:53 momjian Exp $ + * $Id: memutils.h,v 1.20 1999/02/06 16:50:33 wieck Exp $ * * NOTES * some of the information in this file will be moved to @@ -209,12 +209,40 @@ typedef enum AllocMode #define DefaultAllocMode DynamicAllocMode /* + * AllocBlock -- + * Small pieces of memory are taken from bigger blocks of + * memory with a size aligned to a power of two. These + * pieces are not free's separately, instead they are reused + * for the next allocation of a fitting size. + */ +typedef struct AllocBlockData { + struct AllocSetData *aset; + struct AllocBlockData *next; + char *freeptr; + char *endptr; +} AllocBlockData; + +typedef AllocBlockData *AllocBlock; + +/* + * AllocChunk -- + * The prefix of each piece of memory in an AllocBlock + */ +typedef struct AllocChunkData { + void *aset; + Size size; +} AllocChunkData; + +typedef AllocChunkData *AllocChunk; + +/* * AllocSet -- * Allocation set. */ typedef struct AllocSetData { - OrderedSetData setData; + struct AllocBlockData *blocks; + struct AllocChunkData *freelist[8]; /* Note: this will change in the future to support other modes */ } AllocSetData; diff --git a/src/include/utils/palloc.h b/src/include/utils/palloc.h index 2c969df174c..05fccc81a32 100644 --- a/src/include/utils/palloc.h +++ b/src/include/utils/palloc.h @@ -6,18 +6,34 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: palloc.h,v 1.6 1998/09/01 04:39:24 momjian Exp $ + * $Id: palloc.h,v 1.7 1999/02/06 16:50:34 wieck Exp $ * *------------------------------------------------------------------------- */ #ifndef PALLOC_H #define PALLOC_H -#include <c.h> +#include "c.h" -extern void *palloc(Size size); -extern void pfree(void *pointer); -extern void *repalloc(void *pointer, Size size); +#ifdef PALLOC_IS_MALLOC + +# define palloc(s) malloc(s) +# define pfree(p) free(p) +# define repalloc(p,s) realloc((p),(s)) + +#else /* ! PALLOC_IS_MALLOC */ + +/* ---------- + * In the case we use memory contexts, use macro's for palloc() etc. + * ---------- + */ +# include "utils/mcxt.h" + +# define palloc(s) ((void *)MemoryContextAlloc(CurrentMemoryContext,(Size)(s))) +# define pfree(p) MemoryContextFree(CurrentMemoryContext,(Pointer)(p)) +# define repalloc(p,s) ((void *)MemoryContextRealloc(CurrentMemoryContext,(Pointer)(p),(Size)(s))) + +#endif /* PALLOC_IS_MALLOC */ /* like strdup except uses palloc */ extern char *pstrdup(char *pointer); diff --git a/src/include/utils/portal.h b/src/include/utils/portal.h index 2c739721214..b718221cb55 100644 --- a/src/include/utils/portal.h +++ b/src/include/utils/portal.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: portal.h,v 1.10 1998/09/01 04:39:25 momjian Exp $ + * $Id: portal.h,v 1.11 1999/02/06 16:50:34 wieck Exp $ * *------------------------------------------------------------------------- */ @@ -44,8 +44,8 @@ typedef PortalD *Portal; struct PortalD { char *name; /* XXX PortalName */ - struct PortalVariableMemory variable; - struct PortalHeapMemory heap; + struct PortalVariableMemoryData variable; + struct PortalHeapMemoryData heap; QueryDesc *queryDesc; TupleDesc attinfo; EState *state; |