Fixes for perl 5.36 with multiplicity + memleak in $st->kv methods

I always keep messing up the aTHX_ and pTHX_ stuff because my system
perl isn't built with multiplicity, and I still haven't found a
satisfactory way of finding SV leaks. Valgrind can't track those :(
This commit is contained in:
Yorhel 2025-02-12 18:54:10 +01:00
parent 1f7e2de9a0
commit 867543267f
6 changed files with 40 additions and 32 deletions

View file

@ -136,7 +136,7 @@ static SV *fupg_exec_result(pTHX_ PGresult *r) {
return ret;
}
static void fupg_exec_ok(pTHX_ fupg_conn *c, const char *sql) {
static void fupg_exec_ok(fupg_conn *c, const char *sql) {
PGresult *r = PQexec(c->conn, sql);
if (!r) fupg_conn_croak(c, "exec");
if (PQresultStatus(r) != PGRES_COMMAND_OK) fupg_result_croak(r, "exec", sql);
@ -190,7 +190,7 @@ static void fupg_conn_disconnect(fupg_conn *c) {
* to clean up the prepared statement cache at this point. */
}
static void fupg_conn_destroy(fupg_conn *c) {
static void fupg_conn_destroy(pTHX_ fupg_conn *c) {
PQfinish(c->conn);
if (c->buf.sv) SvREFCNT_dec(c->buf.sv);
safefree(c->types);
@ -242,7 +242,7 @@ static const char *fupg_txn_status(fupg_txn *t) {
}
}
static void fupg_txn_commit(pTHX_ fupg_txn *t) {
static void fupg_txn_commit(fupg_txn *t) {
char cmd[64];
if (t->parent) snprintf(cmd, sizeof(cmd), "RELEASE SAVEPOINT fupg_%"UVuf, t->cookie);
else strcpy(cmd, "COMMIT");
@ -250,7 +250,7 @@ static void fupg_txn_commit(pTHX_ fupg_txn *t) {
fupg_exec_ok(t->conn, cmd);
}
static void fupg_txn_rollback(pTHX_ fupg_txn *t) {
static void fupg_txn_rollback(fupg_txn *t) {
t->cookie = 0;
fupg_exec_ok(t->conn, t->rollback_cmd);
}
@ -315,7 +315,7 @@ static void fupg_prepared_prune(fupg_conn *c) {
}
/* Fetch and ref a prepared statement, returns a new object if nothing was cached */
static fupg_prep *fupg_prepared_ref(fupg_conn *c, const char *query) {
static fupg_prep *fupg_prepared_ref(pTHX_ fupg_conn *c, const char *query) {
fupg_prep prep;
prep.hash = kh_hash_str(query);
prep.query = (char *)query;
@ -418,12 +418,12 @@ static const fupg_type *fupg_lookup_type(pTHX_ fupg_conn *c, int *refresh_done,
if ((t = fupg_builtin_byoid(oid))) return t;
if (*refresh_done) return NULL;
*refresh_done = 1;
fupg_refresh_types(c);
fupg_refresh_types(aTHX_ c);
return fupg_type_byoid(c->types, c->ntypes, oid);
}
static const fupg_record *fupg_lookup_record(pTHX_ fupg_conn *c, Oid oid) {
static const fupg_record *fupg_lookup_record(fupg_conn *c, Oid oid) {
khint_t k = fupg_records_get(c->records, oid);
if (k != kh_end(c->records)) return kh_val(c->records, k);