diff options
Diffstat (limited to 'ext/mysqli/mysqli.c')
-rw-r--r-- | ext/mysqli/mysqli.c | 56 |
1 files changed, 38 insertions, 18 deletions
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index a0001ac013..6a4b596848 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -37,32 +37,52 @@ ZEND_DECLARE_MODULE_GLOBALS(mysqli) static zend_object_handlers mysqli_object_handlers; PR_MAIN *prmain; -/* {{{ php_clear_stmt_bind */ -void php_clear_stmt_bind(STMT *stmt) +/* {{{ php_free_stmt_bind_buffer */ +void php_free_stmt_bind_buffer(BIND_BUFFER bbuf, int type) { unsigned int i; - if (stmt->stmt) { - mysql_stmt_close(stmt->stmt); + if (!bbuf.var_cnt) { + return; } - if (stmt->var_cnt) { - for (i = 0; i < stmt->var_cnt; i++) { - if (stmt->type == FETCH_RESULT) { - if (stmt->bind[i].type == IS_STRING) { - efree(stmt->bind[i].buffer); - } - } - if (stmt->vars[i]) { - ZVAL_DELREF(stmt->vars[i]); + if (bbuf.is_null) { + efree(bbuf.is_null); + } + + for (i=0; i < bbuf.var_cnt; i++) { + if (type == FETCH_RESULT) { + if (bbuf.buf[i].type == IS_STRING) { + efree(bbuf.buf[i].buffer); } } - if (stmt->type == FETCH_RESULT) { - efree(stmt->bind); - } - efree(stmt->vars); - efree(stmt->is_null); + if (bbuf.vars[i]) { + ZVAL_DELREF(bbuf.vars[i]); + } + } + + if (bbuf.vars) { + efree(bbuf.vars); + } + + if (type == FETCH_RESULT) { + efree(bbuf.buf); } + bbuf.var_cnt = 0; + return; +} +/* }}} */ + +/* {{{ php_clear_stmt_bind */ +void php_clear_stmt_bind(STMT *stmt) +{ + if (stmt->stmt) { + mysql_stmt_close(stmt->stmt); + } + + php_free_stmt_bind_buffer(stmt->param, FETCH_SIMPLE); + php_free_stmt_bind_buffer(stmt->result, FETCH_RESULT); + efree(stmt); return; } |