diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2024-11-27 12:50:15 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2024-11-27 12:50:23 -0500 |
commit | 2b41de4a5b429c53ae5fb5ff92b2e9822fd2cd9a (patch) | |
tree | d3f053cbe5772addc7c4f4663e2cdfaee30bf5e2 /src/interfaces/ecpg/preproc/descriptor.c | |
parent | 85312d95e959bae16c5d0bbf79ae74bcd7fec1a9 (diff) | |
download | postgresql-2b41de4a5b429c53ae5fb5ff92b2e9822fd2cd9a.tar.gz postgresql-2b41de4a5b429c53ae5fb5ff92b2e9822fd2cd9a.zip |
ecpg: clean up some other assorted memory leaks.
Avoid leaking the prior value when updating the "connection"
state variable.
Ditto for ECPGstruct_sizeof. (It seems like this one ought to
be statement-local, but testing says it isn't, and I didn't
feel like diving deeper.)
The actual_type[] entries are statement-local, though, so
no need to mm_strdup() strings stored in them.
Likewise, sqlda variables are statement-local, so we can
loc_alloc them.
Also clean up sloppiness around management of the argsinsert and
argsresult lists.
progname changes are strictly to prevent valgrind from complaining
about leaked allocations.
With this, valgrind reports zero leakage in the ecpg preprocessor
for all of our ecpg regression test cases.
Discussion: https://postgr.es/m/2011420.1713493114@sss.pgh.pa.us
Diffstat (limited to 'src/interfaces/ecpg/preproc/descriptor.c')
-rw-r--r-- | src/interfaces/ecpg/preproc/descriptor.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/interfaces/ecpg/preproc/descriptor.c b/src/interfaces/ecpg/preproc/descriptor.c index 9b87d07d09f..e8c7016bdc1 100644 --- a/src/interfaces/ecpg/preproc/descriptor.c +++ b/src/interfaces/ecpg/preproc/descriptor.c @@ -344,11 +344,17 @@ descriptor_variable(const char *name, int input) struct variable * sqlda_variable(const char *name) { - struct variable *p = (struct variable *) mm_alloc(sizeof(struct variable)); - - p->name = mm_strdup(name); - p->type = (struct ECPGtype *) mm_alloc(sizeof(struct ECPGtype)); + /* + * Presently, sqlda variables are only needed for the duration of the + * current statement. Rather than add infrastructure to manage them, + * let's just loc_alloc them. + */ + struct variable *p = (struct variable *) loc_alloc(sizeof(struct variable)); + + p->name = loc_strdup(name); + p->type = (struct ECPGtype *) loc_alloc(sizeof(struct ECPGtype)); p->type->type = ECPGt_sqlda; + p->type->type_name = NULL; p->type->size = NULL; p->type->struct_sizeof = NULL; p->type->u.element = NULL; |