summaryrefslogtreecommitdiff
path: root/ext/mysqlnd/mysqlnd_connection.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2017-11-15 00:53:51 +0300
committerDmitry Stogov <dmitry@zend.com>2017-11-15 00:53:51 +0300
commit69462bdf4c9dcfef7056be5e075a7545724004b3 (patch)
tree5a5f5e9790e74887e724a19e5cfd5e87fbb6a97f /ext/mysqlnd/mysqlnd_connection.c
parent492bc8ea576a8b088955becaedf6553e21f76393 (diff)
downloadphp-git-69462bdf4c9dcfef7056be5e075a7545724004b3.tar.gz
Embeded zend_list into st_mysqlnd_error_info, to avoid extra allocation/deallocation.
Diffstat (limited to 'ext/mysqlnd/mysqlnd_connection.c')
-rw-r--r--ext/mysqlnd/mysqlnd_connection.c35
1 files changed, 12 insertions, 23 deletions
diff --git a/ext/mysqlnd/mysqlnd_connection.c b/ext/mysqlnd/mysqlnd_connection.c
index 960b9f10b6..75a7e02926 100644
--- a/ext/mysqlnd/mysqlnd_connection.c
+++ b/ext/mysqlnd/mysqlnd_connection.c
@@ -103,9 +103,7 @@ MYSQLND_METHOD(mysqlnd_error_info, reset)(MYSQLND_ERROR_INFO * const info)
info->error_no = 0;
info->error[0] = '\0';
memset(&info->sqlstate, 0, sizeof(info->sqlstate));
- if (info->error_list) {
- zend_llist_clean(info->error_list);
- }
+ zend_llist_clean(&info->error_list);
DBG_VOID_RETURN;
}
@@ -121,19 +119,18 @@ MYSQLND_METHOD(mysqlnd_error_info, set_client_error)(MYSQLND_ERROR_INFO * const
{
DBG_ENTER("mysqlnd_error_info::set_client_error");
if (err_no) {
+ MYSQLND_ERROR_LIST_ELEMENT error_for_the_list = {0};
+
info->error_no = err_no;
strlcpy(info->sqlstate, sqlstate, sizeof(info->sqlstate));
strlcpy(info->error, error, sizeof(info->error));
- if (info->error_list) {
- MYSQLND_ERROR_LIST_ELEMENT error_for_the_list = {0};
-
- error_for_the_list.error_no = err_no;
- strlcpy(error_for_the_list.sqlstate, sqlstate, sizeof(error_for_the_list.sqlstate));
- error_for_the_list.error = mnd_pestrdup(error, TRUE);
- if (error_for_the_list.error) {
- DBG_INF_FMT("adding error [%s] to the list", error_for_the_list.error);
- zend_llist_add_element(info->error_list, &error_for_the_list);
- }
+
+ error_for_the_list.error_no = err_no;
+ strlcpy(error_for_the_list.sqlstate, sqlstate, sizeof(error_for_the_list.sqlstate));
+ error_for_the_list.error = mnd_pestrdup(error, TRUE);
+ if (error_for_the_list.error) {
+ DBG_INF_FMT("adding error [%s] to the list", error_for_the_list.error);
+ zend_llist_add_element(&info->error_list, &error_for_the_list);
}
} else {
info->m->reset(info);
@@ -158,12 +155,9 @@ mysqlnd_error_info_init(MYSQLND_ERROR_INFO * const info, const zend_bool persist
info->m = mysqlnd_error_info_get_methods();
info->m->reset(info);
- info->error_list = mnd_pecalloc(1, sizeof(zend_llist), persistent);
- if (info->error_list) {
- zend_llist_init(info->error_list, sizeof(MYSQLND_ERROR_LIST_ELEMENT), (llist_dtor_func_t) mysqlnd_error_list_pdtor, persistent);
- }
+ zend_llist_init(&info->error_list, sizeof(MYSQLND_ERROR_LIST_ELEMENT), (llist_dtor_func_t) mysqlnd_error_list_pdtor, persistent);
info->persistent = persistent;
- DBG_RETURN(info->error_list? PASS:FAIL);
+ DBG_RETURN(PASS);
}
/* }}} */
@@ -174,11 +168,6 @@ mysqlnd_error_info_free_contents(MYSQLND_ERROR_INFO * const info)
{
DBG_ENTER("mysqlnd_error_info_free_contents");
info->m->reset(info);
- if (info->error_list) {
- mnd_pefree(info->error_list, info->persistent);
- info->error_list = NULL;
- }
-
DBG_VOID_RETURN;
}
/* }}} */