Author: turnstep
Date: Sun Oct 7 08:45:07 2007
New Revision: 10056
Modified:
DBD-Pg/trunk/Changes
DBD-Pg/trunk/dbdimp.c
Log:
Apply patch from bug 29791 to fix savepoint-related memory fix.
Modified: DBD-Pg/trunk/Changes
==============================================================================
--- DBD-Pg/trunk/Changes (original)
+++ DBD-Pg/trunk/Changes Sun Oct 7 08:45:07 2007
@@ -1,6 +1,8 @@
('GSM' is Greg Sabino Mullane, [EMAIL PROTECTED])
2.0.0
+ - Fix memory leak when using savepoints. (CPAN bug #29791)
+ [EMAIL PROTECTED]
- Allow data_sources to accept optional arguments. [GSM]
- Change versioning system to three numbered system.
- Add support for arrays: can pass in arrayrefs to execute, and
Modified: DBD-Pg/trunk/dbdimp.c
==============================================================================
--- DBD-Pg/trunk/dbdimp.c (original)
+++ DBD-Pg/trunk/dbdimp.c Sun Oct 7 08:45:07 2007
@@ -3002,6 +3002,22 @@
/* ================================================================== */
+/* Pop off savepoints to the specified savepoint name */
+static void pg_db_free_savepoints_to (SV * dbh, imp_dbh_t * imp_dbh, char *
savepoint)
+{
+ I32 i;
+ for (i = av_len(imp_dbh->savepoints); i >= 0; i--) {
+ SV * elem = av_pop(imp_dbh->savepoints);
+ if (strEQ(SvPV_nolen(elem), savepoint)) {
+ sv_2mortal(elem);
+ break;
+ }
+ sv_2mortal(elem);
+ }
+}
+
+
+/* ================================================================== */
int dbd_st_rows (SV * sth, imp_sth_t * imp_sth)
{
if (dbis->debug >= 4)
@@ -3412,12 +3428,7 @@
return 0;
}
- for (i = av_len(imp_dbh->savepoints); i >= 0; i--) {
- SV *elem = *av_fetch(imp_dbh->savepoints, i, 0);
- if (strEQ(SvPV_nolen(elem), savepoint))
- break;
- (void)av_pop(imp_dbh->savepoints);
- }
+ pg_db_free_savepoints_to(dbh, imp_dbh, savepoint);
return 1;
}
@@ -3451,11 +3462,7 @@
return 0;
}
- for (i = av_len(imp_dbh->savepoints); i >= 0; i--) {
- SV *elem = av_pop(imp_dbh->savepoints);
- if (strEQ(SvPV_nolen(elem), savepoint))
- break;
- }
+ pg_db_free_savepoints_to(dbh, imp_dbh, savepoint);
return 1;
}