mirror of
https://github.com/postgres/postgres.git
synced 2025-11-28 11:44:57 +03:00
Change pg_bsd_indent to follow upstream rules for placement of comments
to the right of code, and remove pgindent hack that caused comments
following #endif to not obey the general rule.
Commit e3860ffa4d wasn't actually using
the published version of pg_bsd_indent, but a hacked-up version that
tried to minimize the amount of movement of comments to the right of
code. The situation of interest is where such a comment has to be
moved to the right of its default placement at column 33 because there's
code there. BSD indent has always moved right in units of tab stops
in such cases --- but in the previous incarnation, indent was working
in 8-space tab stops, while now it knows we use 4-space tabs. So the
net result is that in about half the cases, such comments are placed
one tab stop left of before. This is better all around: it leaves
more room on the line for comment text, and it means that in such
cases the comment uniformly starts at the next 4-space tab stop after
the code, rather than sometimes one and sometimes two tabs after.
Also, ensure that comments following #endif are indented the same
as comments following other preprocessor commands such as #else.
That inconsistency turns out to have been self-inflicted damage
from a poorly-thought-through post-indent "fixup" in pgindent.
This patch is much less interesting than the first round of indent
changes, but also bulkier, so I thought it best to separate the effects.
Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
102 lines
3.6 KiB
C
102 lines
3.6 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* memnodes.h
|
|
* POSTGRES memory context node definitions.
|
|
*
|
|
*
|
|
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/nodes/memnodes.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef MEMNODES_H
|
|
#define MEMNODES_H
|
|
|
|
#include "nodes/nodes.h"
|
|
|
|
/*
|
|
* MemoryContextCounters
|
|
* Summarization state for MemoryContextStats collection.
|
|
*
|
|
* The set of counters in this struct is biased towards AllocSet; if we ever
|
|
* add any context types that are based on fundamentally different approaches,
|
|
* we might need more or different counters here. A possible API spec then
|
|
* would be to print only nonzero counters, but for now we just summarize in
|
|
* the format historically used by AllocSet.
|
|
*/
|
|
typedef struct MemoryContextCounters
|
|
{
|
|
Size nblocks; /* Total number of malloc blocks */
|
|
Size freechunks; /* Total number of free chunks */
|
|
Size totalspace; /* Total bytes requested from malloc */
|
|
Size freespace; /* The unused portion of totalspace */
|
|
} MemoryContextCounters;
|
|
|
|
/*
|
|
* MemoryContext
|
|
* A logical context in which memory allocations occur.
|
|
*
|
|
* MemoryContext itself is an abstract type that can have multiple
|
|
* implementations, though for now we have only AllocSetContext.
|
|
* The function pointers in MemoryContextMethods define one specific
|
|
* implementation of MemoryContext --- they are a virtual function table
|
|
* in C++ terms.
|
|
*
|
|
* Node types that are actual implementations of memory contexts must
|
|
* begin with the same fields as MemoryContext.
|
|
*
|
|
* Note: for largely historical reasons, typedef MemoryContext is a pointer
|
|
* to the context struct rather than the struct type itself.
|
|
*/
|
|
|
|
typedef struct MemoryContextMethods
|
|
{
|
|
void *(*alloc) (MemoryContext context, Size size);
|
|
/* call this free_p in case someone #define's free() */
|
|
void (*free_p) (MemoryContext context, void *pointer);
|
|
void *(*realloc) (MemoryContext context, void *pointer, Size size);
|
|
void (*init) (MemoryContext context);
|
|
void (*reset) (MemoryContext context);
|
|
void (*delete_context) (MemoryContext context);
|
|
Size (*get_chunk_space) (MemoryContext context, void *pointer);
|
|
bool (*is_empty) (MemoryContext context);
|
|
void (*stats) (MemoryContext context, int level, bool print,
|
|
MemoryContextCounters *totals);
|
|
#ifdef MEMORY_CONTEXT_CHECKING
|
|
void (*check) (MemoryContext context);
|
|
#endif
|
|
} MemoryContextMethods;
|
|
|
|
|
|
typedef struct MemoryContextData
|
|
{
|
|
NodeTag type; /* identifies exact kind of context */
|
|
/* these two fields are placed here to minimize alignment wastage: */
|
|
bool isReset; /* T = no space alloced since last reset */
|
|
bool allowInCritSection; /* allow palloc in critical section */
|
|
MemoryContextMethods *methods; /* virtual function table */
|
|
MemoryContext parent; /* NULL if no parent (toplevel context) */
|
|
MemoryContext firstchild; /* head of linked list of children */
|
|
MemoryContext prevchild; /* previous child of same parent */
|
|
MemoryContext nextchild; /* next child of same parent */
|
|
char *name; /* context name (just for debugging) */
|
|
MemoryContextCallback *reset_cbs; /* list of reset/delete callbacks */
|
|
} MemoryContextData;
|
|
|
|
/* utils/palloc.h contains typedef struct MemoryContextData *MemoryContext */
|
|
|
|
|
|
/*
|
|
* MemoryContextIsValid
|
|
* True iff memory context is valid.
|
|
*
|
|
* Add new context types to the set accepted by this macro.
|
|
*/
|
|
#define MemoryContextIsValid(context) \
|
|
((context) != NULL && \
|
|
(IsA((context), AllocSetContext) || IsA((context), SlabContext)))
|
|
|
|
#endif /* MEMNODES_H */
|