diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2024-10-28 14:39:01 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2024-10-28 14:39:01 -0400 |
commit | 11b7de4a784135d7a9bce4a29ede092797749efc (patch) | |
tree | ca09a0d69153b39699e83befc1c992e86cdc0c09 /src/include/common/fe_memutils.h | |
parent | bd2843167200f2607972c0defb916daa79ca265f (diff) |
Unify src/common/'s definitions of MaxAllocSize.
As threatened in the previous patch, define MaxAllocSize in
src/include/common/fe_memutils.h rather than having several
copies of it in different src/common/*.c files. This also
provides an opportunity to document it better.
While this would probably be safe to back-patch, I'll refrain
(for now anyway).
Diffstat (limited to 'src/include/common/fe_memutils.h')
-rw-r--r-- | src/include/common/fe_memutils.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/include/common/fe_memutils.h b/src/include/common/fe_memutils.h index 492cc97e8d1..6544ebb44e5 100644 --- a/src/include/common/fe_memutils.h +++ b/src/include/common/fe_memutils.h @@ -10,6 +10,18 @@ #define FE_MEMUTILS_H /* + * Assumed maximum size for allocation requests. + * + * We don't enforce this, so the actual maximum is the platform's SIZE_MAX. + * But it's useful to have it defined in frontend builds, so that common + * code can check for oversized requests without having frontend-vs-backend + * differences. Also, some code relies on MaxAllocSize being no more than + * INT_MAX/2, so rather than setting this to SIZE_MAX, make it the same as + * the backend's value. + */ +#define MaxAllocSize ((Size) 0x3fffffff) /* 1 gigabyte - 1 */ + +/* * Flags for pg_malloc_extended and palloc_extended, deliberately named * the same as the backend flags. */ |