diff options
Diffstat (limited to 'ext/sqlite3/sqlite3.c')
-rw-r--r-- | ext/sqlite3/sqlite3.c | 59 |
1 files changed, 28 insertions, 31 deletions
diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 861d6dfc7a..08d436786f 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -485,7 +485,7 @@ PHP_METHOD(sqlite3, prepare) errcode = sqlite3_prepare_v2(db_obj->db, ZSTR_VAL(sql), ZSTR_LEN(sql), &(stmt_obj->stmt), NULL); if (errcode != SQLITE_OK) { php_sqlite3_error(db_obj, "Unable to prepare statement: %d, %s", errcode, sqlite3_errmsg(db_obj->db)); - zval_dtor(return_value); + zval_ptr_dtor(return_value); RETURN_FALSE; } @@ -572,7 +572,7 @@ PHP_METHOD(sqlite3, query) } sqlite3_finalize(stmt_obj->stmt); stmt_obj->initialised = 0; - zval_dtor(return_value); + zval_ptr_dtor(return_value); RETURN_FALSE; } } @@ -676,7 +676,7 @@ PHP_METHOD(sqlite3, querySingle) if (!entire_row) { RETVAL_NULL(); } else { - array_init(return_value); + ZVAL_EMPTY_ARRAY(return_value); } break; } @@ -724,7 +724,7 @@ static int sqlite3_do_callback(struct php_sqlite3_fci *fc, zval *cb, int argc, s if (Z_ISUNDEF(agg_context->zval_context)) { ZVAL_NULL(&agg_context->zval_context); } - ZVAL_DUP(&zargs[0], &agg_context->zval_context); + ZVAL_COPY(&zargs[0], &agg_context->zval_context); ZVAL_LONG(&zargs[1], agg_context->row_count); } @@ -858,7 +858,7 @@ static void php_sqlite3_callback_final(sqlite3_context *context) /* {{{ */ static int php_sqlite3_callback_compare(void *coll, int a_len, const void *a, int b_len, const void* b) /* {{{ */ { php_sqlite3_collation *collation = (php_sqlite3_collation*)coll; - zval *zargs = NULL; + zval zargs[2]; zval retval; int ret; @@ -868,7 +868,6 @@ static int php_sqlite3_callback_compare(void *coll, int a_len, const void *a, in collation->fci.fci.retval = &retval; collation->fci.fci.param_count = 2; - zargs = safe_emalloc(2, sizeof(zval), 0); ZVAL_STRINGL(&zargs[0], a, a_len); ZVAL_STRINGL(&zargs[1], b, b_len); @@ -885,7 +884,6 @@ static int php_sqlite3_callback_compare(void *coll, int a_len, const void *a, in zval_ptr_dtor(&zargs[0]); zval_ptr_dtor(&zargs[1]); - efree(zargs); if (EG(exception)) { ret = 0; @@ -931,7 +929,7 @@ PHP_METHOD(sqlite3, createFunction) if (!zend_is_callable(callback_func, 0, NULL)) { zend_string *callback_name = zend_get_callable_name(callback_func); php_sqlite3_error(db_obj, "Not a valid callback function %s", ZSTR_VAL(callback_name)); - zend_string_release(callback_name); + zend_string_release_ex(callback_name, 0); RETURN_FALSE; } @@ -980,14 +978,14 @@ PHP_METHOD(sqlite3, createAggregate) if (!zend_is_callable(step_callback, 0, NULL)) { zend_string *callback_name = zend_get_callable_name(step_callback); php_sqlite3_error(db_obj, "Not a valid callback function %s", ZSTR_VAL(callback_name)); - zend_string_release(callback_name); + zend_string_release_ex(callback_name, 0); RETURN_FALSE; } if (!zend_is_callable(fini_callback, 0, NULL)) { zend_string *callback_name = zend_get_callable_name(fini_callback); php_sqlite3_error(db_obj, "Not a valid callback function %s", ZSTR_VAL(callback_name)); - zend_string_release(callback_name); + zend_string_release_ex(callback_name, 0); RETURN_FALSE; } @@ -1036,7 +1034,7 @@ PHP_METHOD(sqlite3, createCollation) if (!zend_is_callable(callback_func, 0, NULL)) { zend_string *callback_name = zend_get_callable_name(callback_func); php_sqlite3_error(db_obj, "Not a valid callback function %s", ZSTR_VAL(callback_name)); - zend_string_release(callback_name); + zend_string_release_ex(callback_name, 0); RETURN_FALSE; } @@ -1205,7 +1203,7 @@ static int php_sqlite3_stream_stat(php_stream *stream, php_stream_statbuf *ssb) return 0; } -static php_stream_ops php_stream_sqlite3_ops = { +static const php_stream_ops php_stream_sqlite3_ops = { php_sqlite3_stream_write, php_sqlite3_stream_read, php_sqlite3_stream_close, @@ -1431,7 +1429,7 @@ static int register_bound_parameter_to_sqlite(struct php_sqlite3_bound_param *pa if (param->param_number < 1) { if (param->name) { - zend_string_release(param->name); + zend_string_release_ex(param->name, 0); } return 0; } @@ -1522,8 +1520,8 @@ PHP_METHOD(sqlite3stmt, bindValue) param.param_number = -1; param.type = SQLITE3_TEXT; - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "lz/|l", ¶m.param_number, ¶meter, ¶m.type) == FAILURE) { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sz/|l", ¶m.name, ¶meter, ¶m.type) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "lz|l", ¶m.param_number, ¶meter, ¶m.type) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sz|l", ¶m.name, ¶meter, ¶m.type) == FAILURE) { return; } } @@ -1616,7 +1614,7 @@ PHP_METHOD(sqlite3stmt, execute) if (buffer) { sqlite3_bind_blob(stmt_obj->stmt, param->param_number, ZSTR_VAL(buffer), ZSTR_LEN(buffer), SQLITE_TRANSIENT); - zend_string_release(buffer); + zend_string_release_ex(buffer, 0); } else { sqlite3_bind_null(stmt_obj->stmt, param->param_number); } @@ -1663,7 +1661,7 @@ PHP_METHOD(sqlite3stmt, execute) if (!EG(exception)) { php_sqlite3_error(stmt_obj->db_obj, "Unable to execute statement: %s", sqlite3_errmsg(sqlite3_db_handle(stmt_obj->stmt))); } - zval_dtor(return_value); + zval_ptr_dtor(return_value); RETURN_FALSE; } @@ -1671,7 +1669,7 @@ PHP_METHOD(sqlite3stmt, execute) } /* }}} */ -/* {{{ proto int SQLite3Stmt::__construct(SQLite3 dbobject, String Statement) +/* {{{ proto SQLite3Stmt::__construct(SQLite3 dbobject, String Statement) __constructor for SQLite3Stmt. */ PHP_METHOD(sqlite3stmt, __construct) { @@ -1706,7 +1704,7 @@ PHP_METHOD(sqlite3stmt, __construct) errcode = sqlite3_prepare_v2(db_obj->db, ZSTR_VAL(sql), ZSTR_LEN(sql), &(stmt_obj->stmt), NULL); if (errcode != SQLITE_OK) { php_sqlite3_error(db_obj, "Unable to prepare statement: %d, %s", errcode, sqlite3_errmsg(db_obj->db)); - zval_dtor(return_value); + zval_ptr_dtor(return_value); RETURN_FALSE; } stmt_obj->initialised = 1; @@ -1893,7 +1891,7 @@ PHP_METHOD(sqlite3result, finalize) } /* }}} */ -/* {{{ proto int SQLite3Result::__construct() +/* {{{ proto SQLite3Result::__construct() __constructor for SQLite3Result. */ PHP_METHOD(sqlite3result, __construct) { @@ -1995,7 +1993,7 @@ ZEND_END_ARG_INFO() /* }}} */ /* {{{ php_sqlite3_class_methods */ -static zend_function_entry php_sqlite3_class_methods[] = { +static const zend_function_entry php_sqlite3_class_methods[] = { PHP_ME(sqlite3, open, arginfo_sqlite3_open, ZEND_ACC_PUBLIC) PHP_ME(sqlite3, close, arginfo_sqlite3_void, ZEND_ACC_PUBLIC) PHP_ME(sqlite3, exec, arginfo_sqlite3_query, ZEND_ACC_PUBLIC) @@ -2024,7 +2022,7 @@ static zend_function_entry php_sqlite3_class_methods[] = { /* }}} */ /* {{{ php_sqlite3_stmt_class_methods */ -static zend_function_entry php_sqlite3_stmt_class_methods[] = { +static const zend_function_entry php_sqlite3_stmt_class_methods[] = { PHP_ME(sqlite3stmt, paramCount, arginfo_sqlite3_void, ZEND_ACC_PUBLIC) PHP_ME(sqlite3stmt, close, arginfo_sqlite3_void, ZEND_ACC_PUBLIC) PHP_ME(sqlite3stmt, reset, arginfo_sqlite3_void, ZEND_ACC_PUBLIC) @@ -2039,7 +2037,7 @@ static zend_function_entry php_sqlite3_stmt_class_methods[] = { /* }}} */ /* {{{ php_sqlite3_result_class_methods */ -static zend_function_entry php_sqlite3_result_class_methods[] = { +static const zend_function_entry php_sqlite3_result_class_methods[] = { PHP_ME(sqlite3result, numColumns, arginfo_sqlite3_void, ZEND_ACC_PUBLIC) PHP_ME(sqlite3result, columnName, arginfo_sqlite3result_columnname, ZEND_ACC_PUBLIC) PHP_ME(sqlite3result, columnType, arginfo_sqlite3result_columntype, ZEND_ACC_PUBLIC) @@ -2204,7 +2202,7 @@ static zend_object *php_sqlite3_object_new(zend_class_entry *class_type) /* {{{ php_sqlite3_db_object *intern; /* Allocate memory for it */ - intern = ecalloc(1, sizeof(php_sqlite3_db_object) + zend_object_properties_size(class_type)); + intern = zend_object_alloc(sizeof(php_sqlite3_db_object), class_type); /* Need to keep track of things to free */ zend_llist_init(&(intern->free_list), sizeof(php_sqlite3_free_list *), (llist_dtor_func_t)php_sqlite3_free_list_dtor, 0); @@ -2223,7 +2221,7 @@ static zend_object *php_sqlite3_stmt_object_new(zend_class_entry *class_type) /* php_sqlite3_stmt *intern; /* Allocate memory for it */ - intern = ecalloc(1, sizeof(php_sqlite3_stmt) + zend_object_properties_size(class_type)); + intern = zend_object_alloc(sizeof(php_sqlite3_stmt), class_type); zend_object_std_init(&intern->zo, class_type); object_properties_init(&intern->zo, class_type); @@ -2239,7 +2237,7 @@ static zend_object *php_sqlite3_result_object_new(zend_class_entry *class_type) php_sqlite3_result *intern; /* Allocate memory for it */ - intern = ecalloc(1, sizeof(php_sqlite3_result) + zend_object_properties_size(class_type)); + intern = zend_object_alloc(sizeof(php_sqlite3_result), class_type); zend_object_std_init(&intern->zo, class_type); object_properties_init(&intern->zo, class_type); @@ -2255,7 +2253,7 @@ static void sqlite3_param_dtor(zval *data) /* {{{ */ struct php_sqlite3_bound_param *param = (struct php_sqlite3_bound_param*)Z_PTR_P(data); if (param->name) { - zend_string_release(param->name); + zend_string_release_ex(param->name, 0); } if (!Z_ISNULL(param->parameter)) { @@ -2280,9 +2278,9 @@ PHP_MINIT_FUNCTION(sqlite3) } #endif - memcpy(&sqlite3_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); - memcpy(&sqlite3_stmt_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); - memcpy(&sqlite3_result_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); + memcpy(&sqlite3_object_handlers, &std_object_handlers, sizeof(zend_object_handlers)); + memcpy(&sqlite3_stmt_object_handlers, &std_object_handlers, sizeof(zend_object_handlers)); + memcpy(&sqlite3_result_object_handlers, &std_object_handlers, sizeof(zend_object_handlers)); /* Register SQLite 3 Class */ INIT_CLASS_ENTRY(ce, "SQLite3", php_sqlite3_class_methods); @@ -2348,7 +2346,6 @@ PHP_MINFO_FUNCTION(sqlite3) { php_info_print_table_start(); php_info_print_table_header(2, "SQLite3 support", "enabled"); - php_info_print_table_row(2, "SQLite3 module version", PHP_SQLITE3_VERSION); php_info_print_table_row(2, "SQLite Library", sqlite3_libversion()); php_info_print_table_end(); |