Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit097fe19

Browse files
committed
Move memory context callback declarations into palloc.h.
Initial experience with this feature suggests that instances ofMemoryContextCallback are likely to propagate into some widely-used headersover time. As things stood, that would result in pulling memutils.h orat least memnodes.h into common headers, which does not seem desirable.Instead, let's decide that this feature is part of the "ordinary pallocuser" API rather than the "specialized context management" API, and assuch should be declared in palloc.h not memutils.h.
1 parente059e02 commit097fe19

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

‎src/include/nodes/memnodes.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,6 @@
1616

1717
#include"nodes/nodes.h"
1818

19-
/*
20-
* A memory context can have callback functions registered on it. Any such
21-
* function will be called once just before the context is next reset or
22-
* deleted. The MemoryContextCallback struct describing such a callback
23-
* typically would be allocated within the context itself, thereby avoiding
24-
* any need to manage it explicitly (the reset/delete action will free it).
25-
*/
26-
typedefvoid (*MemoryContextCallbackFunction) (void*arg);
27-
28-
typedefstructMemoryContextCallback
29-
{
30-
MemoryContextCallbackFunctionfunc;/* function to call */
31-
void*arg;/* argument to pass it */
32-
structMemoryContextCallback*next;/* next in list of callbacks */
33-
}MemoryContextCallback;
34-
3519
/*
3620
* MemoryContext
3721
*A logical context in which memory allocations occur.

‎src/include/utils/memutils.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ extern void MemoryContextDelete(MemoryContext context);
9797
externvoidMemoryContextResetOnly(MemoryContextcontext);
9898
externvoidMemoryContextResetChildren(MemoryContextcontext);
9999
externvoidMemoryContextDeleteChildren(MemoryContextcontext);
100-
externvoidMemoryContextRegisterResetCallback(MemoryContextcontext,
101-
MemoryContextCallback*cb);
102100
externvoidMemoryContextSetParent(MemoryContextcontext,
103101
MemoryContextnew_parent);
104102
externSizeGetMemoryChunkSpace(void*pointer);

‎src/include/utils/palloc.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@
3535
*/
3636
typedefstructMemoryContextData*MemoryContext;
3737

38+
/*
39+
* A memory context can have callback functions registered on it. Any such
40+
* function will be called once just before the context is next reset or
41+
* deleted. The MemoryContextCallback struct describing such a callback
42+
* typically would be allocated within the context itself, thereby avoiding
43+
* any need to manage it explicitly (the reset/delete action will free it).
44+
*/
45+
typedefvoid (*MemoryContextCallbackFunction) (void*arg);
46+
47+
typedefstructMemoryContextCallback
48+
{
49+
MemoryContextCallbackFunctionfunc;/* function to call */
50+
void*arg;/* argument to pass it */
51+
structMemoryContextCallback*next;/* next in list of callbacks */
52+
}MemoryContextCallback;
53+
3854
/*
3955
* CurrentMemoryContext is the default allocation context for palloc().
4056
* Avoid accessing it directly! Instead, use MemoryContextSwitchTo()
@@ -107,6 +123,10 @@ MemoryContextSwitchTo(MemoryContext context)
107123
#endif/* PG_USE_INLINE || MCXT_INCLUDE_DEFINITIONS */
108124
#endif/* FRONTEND */
109125

126+
/* Registration of memory context reset/delete callbacks */
127+
externvoidMemoryContextRegisterResetCallback(MemoryContextcontext,
128+
MemoryContextCallback*cb);
129+
110130
/*
111131
* These are like standard strdup() except the copied string is
112132
* allocated in a context, not with malloc().

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp