aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/misc/tzparser.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2022-10-14 12:10:48 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2022-10-14 12:10:48 -0400
commit407b50f2d421bca5b134a0033176ea8f8c68dc6b (patch)
treefd62b3acfe7b3a764b386ee5d3e643644fc4fc00 /src/backend/utils/misc/tzparser.c
parent9c911ec065df0f660e3add65d986f95928914375 (diff)
downloadpostgresql-407b50f2d421bca5b134a0033176ea8f8c68dc6b.tar.gz
postgresql-407b50f2d421bca5b134a0033176ea8f8c68dc6b.zip
Store GUC data in a memory context, instead of using malloc().
The only real argument for using malloc directly was that we needed the ability to not throw error on OOM; but mcxt.c grew that feature awhile ago. Keeping the data in a memory context improves accountability and debuggability --- for example, without this it's almost impossible to detect memory leaks in the GUC code with anything less costly than valgrind. Moreover, the next patch in this series will add a hash table for GUC lookup, and it'd be pretty silly to be using palloc-dependent hash facilities alongside malloc'd storage of the underlying data. This is a bit invasive though, in particular causing an API break for GUC check hooks that want to modify the GUC's value or use an "extra" data structure. They must now use guc_malloc() and guc_free() instead of malloc() and free(). Failure to change affected code will result in assertion failures or worse; but thanks to recent effort in the mcxt infrastructure, it shouldn't be too hard to diagnose such oversights (at least in assert-enabled builds). One note is that this changes ParseLongOption() to return short-lived palloc'd not malloc'd data. There wasn't any caller for which the previous definition was better. Discussion: https://postgr.es/m/2982579.1662416866@sss.pgh.pa.us
Diffstat (limited to 'src/backend/utils/misc/tzparser.c')
-rw-r--r--src/backend/utils/misc/tzparser.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/utils/misc/tzparser.c b/src/backend/utils/misc/tzparser.c
index 8f2c95f0550..e291cb63b02 100644
--- a/src/backend/utils/misc/tzparser.c
+++ b/src/backend/utils/misc/tzparser.c
@@ -439,7 +439,7 @@ ParseTzFile(const char *filename, int depth,
* load_tzoffsets --- read and parse the specified timezone offset file
*
* On success, return a filled-in TimeZoneAbbrevTable, which must have been
- * malloc'd not palloc'd. On failure, return NULL, using GUC_check_errmsg
+ * guc_malloc'd not palloc'd. On failure, return NULL, using GUC_check_errmsg
* and friends to give details of the problem.
*/
TimeZoneAbbrevTable *