diff --git a/src/backend/utils/mmgr/generation.c b/src/backend/utils/mmgr/generation.c index e530e272e0..d7eeefe510 100644 --- a/src/backend/utils/mmgr/generation.c +++ b/src/backend/utils/mmgr/generation.c @@ -89,7 +89,6 @@ typedef struct GenerationContext struct GenerationBlock { dlist_node node; /* doubly-linked list of blocks */ - Size blksize; /* allocated size of this block */ int nchunks; /* number of chunks in the block */ int nfree; /* number of free chunks */ char *freeptr; /* start of free space in this block */ @@ -414,7 +413,6 @@ GenerationAlloc(MemoryContext context, Size size) context->mem_allocated += blksize; /* block with a single (used) chunk */ - block->blksize = blksize; block->nchunks = 1; block->nfree = 0; @@ -576,7 +574,6 @@ GenerationAlloc(MemoryContext context, Size size) static inline void GenerationBlockInit(GenerationBlock *block, Size blksize) { - block->blksize = blksize; block->nchunks = 0; block->nfree = 0; @@ -647,10 +644,10 @@ GenerationBlockFree(GenerationContext *set, GenerationBlock *block) /* release the block from the list of blocks */ dlist_delete(&block->node); - ((MemoryContext) set)->mem_allocated -= block->blksize; + ((MemoryContext) set)->mem_allocated -= block->endptr - ((char *) block); #ifdef CLOBBER_FREED_MEMORY - wipe_mem(block, block->blksize); + wipe_mem(block, block->endptr - ((char *) block)); #endif free(block); @@ -732,7 +729,7 @@ GenerationFree(MemoryContext context, void *pointer) */ dlist_delete(&block->node); - context->mem_allocated -= block->blksize; + context->mem_allocated -= block->endptr - ((char *) block); free(block); } @@ -926,7 +923,7 @@ GenerationStats(MemoryContext context, nblocks++; nchunks += block->nchunks; nfreechunks += block->nfree; - totalspace += block->blksize; + totalspace += block->endptr - ((char *) block); freespace += (block->endptr - block->freeptr); } @@ -977,7 +974,7 @@ GenerationCheck(MemoryContext context) nchunks; char *ptr; - total_allocated += block->blksize; + total_allocated += block->endptr - ((char *) block); /* * nfree > nchunks is surely wrong. Equality is allowed as the block