1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-07 00:36:50 +03:00

Convert MemoryContextSwitchTo() into an inline function when using GCC.

This commit is contained in:
Tom Lane
2005-02-18 21:52:34 +00:00
parent 477a64d9c8
commit a8593a3463
2 changed files with 28 additions and 2 deletions

View File

@ -21,7 +21,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/utils/palloc.h,v 1.32 2004/12/31 22:03:46 pgsql Exp $
* $PostgreSQL: pgsql/src/include/utils/palloc.h,v 1.33 2005/02/18 21:52:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -70,8 +70,26 @@ extern void pfree(void *pointer);
extern void *repalloc(void *pointer, Size size);
/*
* MemoryContextSwitchTo can't be a macro in standard C compilers.
* But we can make it an inline function when using GCC.
*/
#ifdef __GNUC__
static __inline__ MemoryContext
MemoryContextSwitchTo(MemoryContext context)
{
MemoryContext old = CurrentMemoryContext;
CurrentMemoryContext = context;
return old;
}
#else
extern MemoryContext MemoryContextSwitchTo(MemoryContext context);
#endif /* __GNUC__ */
/*
* These are like standard strdup() except the copied string is
* allocated in a context, not with malloc().