Skip to content

Commit 5917890

Browse files
committed
pgsqlSetNoticeCallback: code cleanup
Move callback cleanup to a separate function.
1 parent fb326d1 commit 5917890

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

ext/pdo_pgsql/pgsql_driver.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,15 @@ static int pdo_pgsql_fetch_error_func(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *in
133133
}
134134
/* }}} */
135135

136+
static void pdo_pgsql_cleanup_notice_callback(pdo_pgsql_db_handle *H) /* {{{ */
137+
{
138+
if (H->notice_callback) {
139+
efree(H->notice_callback);
140+
H->notice_callback = NULL;
141+
}
142+
}
143+
/* }}} */
144+
136145
/* {{{ pdo_pgsql_create_lob_stream */
137146
static ssize_t pgsql_lob_write(php_stream *stream, const char *buf, size_t count)
138147
{
@@ -1161,10 +1170,7 @@ static PHP_METHOD(PDO, pgsqlSetNoticeCallback)
11611170
H = (pdo_pgsql_db_handle *)dbh->driver_data;
11621171

11631172
if (Z_TYPE_P(callback) == IS_NULL) {
1164-
if (H->notice_callback) {
1165-
efree(H->notice_callback);
1166-
H->notice_callback = NULL;
1167-
}
1173+
pdo_pgsql_cleanup_notice_callback(H);
11681174
RETURN_TRUE;
11691175
} else {
11701176
if (!(fc = H->notice_callback)) {

0 commit comments

Comments
 (0)