PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "port/pg_bitutils.h"
#include "utils/memdebug.h"
#include "utils/memutils.h"
Go to the source code of this file.
Data Structures | |
struct | AllocSetContext |
struct | AllocBlockData |
struct | AllocChunkData |
struct | AllocSetFreeList |
Macros | |
#define | ALLOC_MINBITS 3 /* smallest chunk size is 8 bytes */ |
#define | ALLOCSET_NUM_FREELISTS 11 |
#define | ALLOC_CHUNK_LIMIT (1 << (ALLOCSET_NUM_FREELISTS-1+ALLOC_MINBITS)) |
#define | ALLOC_CHUNK_FRACTION 4 |
#define | ALLOC_BLOCKHDRSZ MAXALIGN(sizeof(AllocBlockData)) |
#define | ALLOC_CHUNKHDRSZ sizeof(struct AllocChunkData) |
#define | ALLOCCHUNK_RAWSIZE (SIZEOF_SIZE_T + SIZEOF_VOID_P) |
#define | ALLOCCHUNK_PRIVATE_LEN offsetof(AllocChunkData, aset) |
#define | AllocPointerIsValid(pointer) PointerIsValid(pointer) |
#define | AllocSetIsValid(set) PointerIsValid(set) |
#define | AllocPointerGetChunk(ptr) ((AllocChunk)(((char *)(ptr)) - ALLOC_CHUNKHDRSZ)) |
#define | AllocChunkGetPointer(chk) ((AllocPointer)(((char *)(chk)) + ALLOC_CHUNKHDRSZ)) |
#define | MAX_FREE_CONTEXTS 100 /* arbitrary limit on freelist length */ |
Typedefs | |
typedef struct AllocBlockData * | AllocBlock |
typedef struct AllocChunkData * | AllocChunk |
typedef void * | AllocPointer |
typedef struct AllocSetContext | AllocSetContext |
typedef AllocSetContext * | AllocSet |
typedef struct AllocBlockData | AllocBlockData |
typedef struct AllocChunkData | AllocChunkData |
typedef struct AllocSetFreeList | AllocSetFreeList |
Functions | |
static void * | AllocSetAlloc (MemoryContext context, Size size) |
static void | AllocSetFree (MemoryContext context, void *pointer) |
static void * | AllocSetRealloc (MemoryContext context, void *pointer, Size size) |
static void | AllocSetReset (MemoryContext context) |
static void | AllocSetDelete (MemoryContext context) |
static Size | AllocSetGetChunkSpace (MemoryContext context, void *pointer) |
static bool | AllocSetIsEmpty (MemoryContext context) |
static void | AllocSetStats (MemoryContext context, MemoryStatsPrintFunc printfunc, void *passthru, MemoryContextCounters *totals, bool print_to_stderr) |
static int | AllocSetFreeIndex (Size size) |
MemoryContext | AllocSetContextCreateInternal (MemoryContext parent, const char *name, Size minContextSize, Size initBlockSize, Size maxBlockSize) |
Variables | |
static AllocSetFreeList | context_freelists [2] |
static const MemoryContextMethods | AllocSetMethods |
#define ALLOC_BLOCKHDRSZ MAXALIGN(sizeof(AllocBlockData)) |
#define ALLOC_CHUNK_LIMIT (1 << (ALLOCSET_NUM_FREELISTS-1+ALLOC_MINBITS)) |
#define ALLOC_CHUNKHDRSZ sizeof(struct AllocChunkData) |
#define ALLOCCHUNK_PRIVATE_LEN offsetof(AllocChunkData, aset) |
#define AllocChunkGetPointer | ( | chk | ) | ((AllocPointer)(((char *)(chk)) + ALLOC_CHUNKHDRSZ)) |
#define AllocPointerGetChunk | ( | ptr | ) | ((AllocChunk)(((char *)(ptr)) - ALLOC_CHUNKHDRSZ)) |
#define AllocPointerIsValid | ( | pointer | ) | PointerIsValid(pointer) |
#define AllocSetIsValid | ( | set | ) | PointerIsValid(set) |
#define MAX_FREE_CONTEXTS 100 /* arbitrary limit on freelist length */ |
typedef struct AllocBlockData* AllocBlock |
typedef struct AllocBlockData AllocBlockData |
typedef struct AllocChunkData* AllocChunk |
typedef struct AllocChunkData AllocChunkData |
typedef void* AllocPointer |
typedef AllocSetContext* AllocSet |
typedef struct AllocSetContext AllocSetContext |
typedef struct AllocSetFreeList AllocSetFreeList |
|
static |
Definition at line 721 of file aset.c.
References ALLOC_BLOCKHDRSZ, ALLOC_CHUNKHDRSZ, ALLOC_MINBITS, ALLOCCHUNK_PRIVATE_LEN, AllocChunkGetPointer, AllocSetContext::allocChunkLimit, AllocSetFreeIndex(), AllocSetIsValid, AllocBlockData::aset, AllocChunkData::aset, Assert(), AssertArg, AllocSetContext::blocks, AllocBlockData::endptr, AllocSetContext::freelist, AllocBlockData::freeptr, malloc, MAXALIGN, AllocSetContext::maxBlockSize, MemoryContextData::mem_allocated, AllocBlockData::next, AllocSetContext::nextBlockSize, AllocBlockData::prev, AllocChunkData::size, VALGRIND_MAKE_MEM_NOACCESS, and VALGRIND_MAKE_MEM_UNDEFINED.
Referenced by AllocSetRealloc().
MemoryContext AllocSetContextCreateInternal | ( | MemoryContext | parent, |
const char * | name, | ||
Size | minContextSize, | ||
Size | initBlockSize, | ||
Size | maxBlockSize | ||
) |
Definition at line 379 of file aset.c.
References ALLOC_BLOCKHDRSZ, ALLOC_CHUNK_FRACTION, ALLOC_CHUNK_LIMIT, ALLOC_CHUNKHDRSZ, AllocSetContext::allocChunkLimit, AllocHugeSizeIsValid, ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MINSIZE, ALLOCSET_SEPARATE_THRESHOLD, ALLOCSET_SMALL_INITSIZE, ALLOCSET_SMALL_MINSIZE, AllocSetMethods, AllocBlockData::aset, Assert(), AllocSetContext::blocks, context_freelists, AllocBlockData::endptr, ereport, errcode(), errdetail(), errmsg(), ERROR, AllocSetFreeList::first_free, AllocSetContext::freelist, AllocSetContext::freeListIndex, AllocBlockData::freeptr, AllocSetContext::header, AllocSetContext::initBlockSize, AllocSetContext::keeper, malloc, Max, MAXALIGN, AllocSetContext::maxBlockSize, MemoryContextCreate(), MemoryContextStats(), MemSetAligned, name, AllocBlockData::next, AllocSetContext::nextBlockSize, MemoryContextData::nextchild, AllocSetFreeList::num_free, offsetof, AllocBlockData::prev, StaticAssertStmt, T_AllocSetContext, TopMemoryContext, and VALGRIND_MAKE_MEM_NOACCESS.
|
static |
Definition at line 627 of file aset.c.
References AllocSetIsValid, Assert(), AssertArg, AllocSetContext::blocks, context_freelists, AllocBlockData::endptr, AllocSetFreeList::first_free, free, AllocSetContext::freeListIndex, AllocBlockData::freeptr, AllocSetContext::header, MemoryContextData::isReset, AllocSetContext::keeper, MAX_FREE_CONTEXTS, MemoryContextData::mem_allocated, MemoryContextResetOnly(), next, AllocBlockData::next, MemoryContextData::nextchild, AllocSetFreeList::num_free, and PG_USED_FOR_ASSERTS_ONLY.
|
static |
Definition at line 993 of file aset.c.
References ALLOC_BLOCKHDRSZ, ALLOC_CHUNKHDRSZ, ALLOCCHUNK_PRIVATE_LEN, AllocSetContext::allocChunkLimit, AllocPointerGetChunk, AllocSetFreeIndex(), AllocBlockData::aset, AllocChunkData::aset, AllocSetContext::blocks, elog, AllocBlockData::endptr, ERROR, free, AllocSetContext::freelist, AllocBlockData::freeptr, AllocSetContext::header, MemoryContextData::mem_allocated, MemoryContextData::name, AllocBlockData::next, AllocBlockData::prev, AllocChunkData::size, VALGRIND_MAKE_MEM_DEFINED, and WARNING.
Referenced by AllocSetRealloc().
|
inlinestatic |
Definition at line 309 of file aset.c.
References ALLOC_CHUNK_LIMIT, ALLOC_MINBITS, ALLOCSET_NUM_FREELISTS, Assert(), idx(), pg_leftmost_one_pos, and StaticAssertStmt.
Referenced by AllocSetAlloc(), and AllocSetFree().
|
static |
Definition at line 1304 of file aset.c.
References ALLOC_CHUNKHDRSZ, ALLOCCHUNK_PRIVATE_LEN, AllocPointerGetChunk, AllocChunkData::size, VALGRIND_MAKE_MEM_DEFINED, and VALGRIND_MAKE_MEM_NOACCESS.
|
static |
|
static |
Definition at line 1075 of file aset.c.
References ALLOC_BLOCKHDRSZ, ALLOC_CHUNKHDRSZ, ALLOCCHUNK_PRIVATE_LEN, AllocChunkGetPointer, AllocSetContext::allocChunkLimit, AllocPointerGetChunk, AllocSetAlloc(), AllocSetFree(), AllocBlockData::aset, AllocSetContext::blocks, elog, AllocBlockData::endptr, ERROR, AllocBlockData::freeptr, AllocSetContext::header, Max, MAXALIGN, MemoryContextData::mem_allocated, MemoryContextData::name, AllocBlockData::next, AllocBlockData::prev, realloc, AllocChunkData::size, VALGRIND_MAKE_MEM_DEFINED, VALGRIND_MAKE_MEM_NOACCESS, VALGRIND_MAKE_MEM_UNDEFINED, and WARNING.
|
static |
Definition at line 559 of file aset.c.
References ALLOC_BLOCKHDRSZ, AllocSetIsValid, Assert(), AssertArg, AllocSetContext::blocks, AllocBlockData::endptr, free, AllocSetContext::freelist, AllocBlockData::freeptr, AllocSetContext::initBlockSize, AllocSetContext::keeper, MemoryContextData::mem_allocated, MemSetAligned, next, AllocBlockData::next, AllocSetContext::nextBlockSize, PG_USED_FOR_ASSERTS_ONLY, AllocBlockData::prev, and VALGRIND_MAKE_MEM_NOACCESS.
|
static |
Definition at line 1343 of file aset.c.
References ALLOC_CHUNKHDRSZ, ALLOCSET_NUM_FREELISTS, AllocChunkData::aset, AllocSetContext::blocks, AllocBlockData::endptr, MemoryContextCounters::freechunks, AllocSetContext::freelist, AllocBlockData::freeptr, MemoryContextCounters::freespace, MAXALIGN, MemoryContextCounters::nblocks, AllocBlockData::next, AllocChunkData::size, snprintf, and MemoryContextCounters::totalspace.
|
static |
Definition at line 285 of file aset.c.
Referenced by AllocSetContextCreateInternal().
|
static |
Definition at line 253 of file aset.c.
Referenced by AllocSetContextCreateInternal(), and AllocSetDelete().