diff options
Diffstat (limited to 'src/backend/utils')
-rw-r--r-- | src/backend/utils/mmgr/aset.c | 24 | ||||
-rw-r--r-- | src/backend/utils/mmgr/mcxt.c | 24 |
2 files changed, 44 insertions, 4 deletions
diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c index 79da5fe0175..b25d870059a 100644 --- a/src/backend/utils/mmgr/aset.c +++ b/src/backend/utils/mmgr/aset.c @@ -11,7 +11,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mmgr/aset.c,v 1.57 2004/08/29 05:06:51 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mmgr/aset.c,v 1.58 2004/09/16 20:17:33 tgl Exp $ * * NOTE: * This is a new (Feb. 05, 1999) implementation of the allocation set @@ -205,6 +205,7 @@ static void AllocSetInit(MemoryContext context); 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); #ifdef MEMORY_CONTEXT_CHECKING @@ -222,6 +223,7 @@ static MemoryContextMethods AllocSetMethods = { AllocSetReset, AllocSetDelete, AllocSetGetChunkSpace, + AllocSetIsEmpty, AllocSetStats #ifdef MEMORY_CONTEXT_CHECKING ,AllocSetCheck @@ -992,6 +994,26 @@ AllocSetGetChunkSpace(MemoryContext context, void *pointer) } /* + * AllocSetIsEmpty + * Is an allocset empty of any allocated space? + */ +static bool +AllocSetIsEmpty(MemoryContext context) +{ + AllocSet set = (AllocSet) context; + + /* + * For now, we say "empty" only if the context never contained any + * space at all. We could examine the freelists to determine if all + * space has been freed, but it's not really worth the trouble for + * present uses of this functionality. + */ + if (set->blocks == NULL) + return true; + return false; +} + +/* * AllocSetStats * Displays stats about memory consumption of an allocset. */ diff --git a/src/backend/utils/mmgr/mcxt.c b/src/backend/utils/mmgr/mcxt.c index f8e0af4f8b0..581c7f396d8 100644 --- a/src/backend/utils/mmgr/mcxt.c +++ b/src/backend/utils/mmgr/mcxt.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mmgr/mcxt.c,v 1.50 2004/08/29 05:06:51 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mmgr/mcxt.c,v 1.51 2004/09/16 20:17:33 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -292,6 +292,25 @@ GetMemoryChunkContext(void *pointer) } /* + * MemoryContextIsEmpty + * Is a memory context empty of any allocated space? + */ +bool +MemoryContextIsEmpty(MemoryContext context) +{ + AssertArg(MemoryContextIsValid(context)); + + /* + * For now, we consider a memory context nonempty if it has any children; + * perhaps this should be changed later. + */ + if (context->firstchild != NULL) + return false; + /* Otherwise use the type-specific inquiry */ + return (*context->methods->is_empty) (context); +} + +/* * MemoryContextStats * Print statistics about the named context and all its descendants. * @@ -662,7 +681,6 @@ void pgport_pfree(void *pointer) { pfree(pointer); - return; } -#endif +#endif /* WIN32 */ |