Hi all, While hacking on an extension, I have finished by doing things similar to guc_malloc & friends for the allocation of a GUC parameter for malloc portability. While that's not really a big deal to copy/paste this code, I am wondering if it would make sense to expose them for extension developers. Please see the attached for the simple idea.
Thanks, -- Michael
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index f496ad6281..e548473fb3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4203,9 +4203,10 @@ static void replace_auto_config_value(ConfigVariable **head_p, ConfigVariable ** /* - * Some infrastructure for checking malloc/strdup/realloc calls + * Some infrastructure for checking malloc/strdup/realloc calls with + * GUC parameters. */ -static void * +void * guc_malloc(int elevel, size_t size) { void *data; @@ -4221,7 +4222,7 @@ guc_malloc(int elevel, size_t size) return data; } -static void * +void * guc_realloc(int elevel, void *old, size_t size) { void *data; @@ -4237,7 +4238,7 @@ guc_realloc(int elevel, void *old, size_t size) return data; } -static char * +char * guc_strdup(int elevel, const char *src) { char *data; diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h index 3d13a33b94..280249a257 100644 --- a/src/include/utils/guc.h +++ b/src/include/utils/guc.h @@ -415,6 +415,10 @@ extern void GUC_check_errcode(int sqlerrcode); pre_format_elog_string(errno, TEXTDOMAIN), \ GUC_check_errhint_string = format_elog_string +/* Support for GUC allocation */ +extern void *guc_malloc(int elevel, size_t size); +extern void *guc_realloc(int elevel, void *old, size_t size); +extern char *guc_strdup(int elevel, const char *src); /* * The following functions are not in guc.c, but are declared here to avoid
signature.asc
Description: PGP signature