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

Commit11b7de4

Browse files
committed
Unify src/common/'s definitions of MaxAllocSize.
As threatened in the previous patch, define MaxAllocSize insrc/include/common/fe_memutils.h rather than having severalcopies of it in different src/common/*.c files. This alsoprovides an opportunity to document it better.While this would probably be safe to back-patch, I'll refrain(for now anyway).
1 parentbd28431 commit11b7de4

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

‎src/common/psprintf.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424

2525
#include"postgres_fe.h"
2626

27-
/* It's possible we could use a different value for this in frontend code */
28-
#defineMaxAllocSize((Size) 0x3fffffff)/* 1 gigabyte - 1 */
29-
3027
#endif
3128

3229

‎src/common/saslprep.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
#include"utils/memutils.h"
2525
#else
2626
#include"postgres_fe.h"
27-
28-
/* It's possible we could use a different value for this in frontend code */
29-
#defineMaxAllocSize((Size) 0x3fffffff)/* 1 gigabyte - 1 */
30-
3127
#endif
3228

3329
#include"common/saslprep.h"

‎src/common/stringinfo.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424

2525
#include"postgres_fe.h"
2626

27-
/* It's possible we could use a different value for this in frontend code */
28-
#defineMaxAllocSize((Size) 0x3fffffff)/* 1 gigabyte - 1 */
29-
3027
#endif
3128

3229
#include"lib/stringinfo.h"

‎src/include/common/fe_memutils.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@
99
#ifndefFE_MEMUTILS_H
1010
#defineFE_MEMUTILS_H
1111

12+
/*
13+
* Assumed maximum size for allocation requests.
14+
*
15+
* We don't enforce this, so the actual maximum is the platform's SIZE_MAX.
16+
* But it's useful to have it defined in frontend builds, so that common
17+
* code can check for oversized requests without having frontend-vs-backend
18+
* differences. Also, some code relies on MaxAllocSize being no more than
19+
* INT_MAX/2, so rather than setting this to SIZE_MAX, make it the same as
20+
* the backend's value.
21+
*/
22+
#defineMaxAllocSize((Size) 0x3fffffff)/* 1 gigabyte - 1 */
23+
1224
/*
1325
* Flags for pg_malloc_extended and palloc_extended, deliberately named
1426
* the same as the backend flags.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp