--- embedaddon/php/ext/mysqlnd/mysqlnd_ps_codec.c 2012/02/21 23:47:58 1.1.1.1 +++ embedaddon/php/ext/mysqlnd/mysqlnd_ps_codec.c 2012/05/29 12:34:41 1.1.1.2 @@ -12,13 +12,13 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Georg Richter | - | Andrey Hristov | + | Authors: Andrey Hristov | | Ulf Wendel | + | Georg Richter | +----------------------------------------------------------------------+ */ -/* $Id: mysqlnd_ps_codec.c,v 1.1.1.1 2012/02/21 23:47:58 misho Exp $ */ +/* $Id: mysqlnd_ps_codec.c,v 1.1.1.2 2012/05/29 12:34:41 misho Exp $ */ #include "php.h" #include "mysqlnd.h" #include "mysqlnd_wireprotocol.h" @@ -258,18 +258,14 @@ void ps_fetch_time(zval *zv, const MYSQLND_FIELD * con t.time_type = MYSQLND_TIMESTAMP_TIME; } - /* - QQ : How to make this unicode without copying two times the buffer - - Unicode equivalent of spprintf? - */ - length = spprintf(&value, 0, "%s%02u:%02u:%02u", (t.neg ? "-" : ""), t.hour, t.minute, t.second); + length = mnd_sprintf(&value, 0, "%s%02u:%02u:%02u", (t.neg ? "-" : ""), t.hour, t.minute, t.second); DBG_INF_FMT("%s", value); #if MYSQLND_UNICODE if (!as_unicode) { #endif ZVAL_STRINGL(zv, value, length, 1); - efree(value); /* allocated by spprintf */ + mnd_sprintf_free(value); #if MYSQLND_UNICODE } else { ZVAL_UTF8_STRINGL(zv, value, length, ZSTR_AUTOFREE); @@ -309,18 +305,14 @@ void ps_fetch_date(zval *zv, const MYSQLND_FIELD * con t.time_type = MYSQLND_TIMESTAMP_DATE; } - /* - QQ : How to make this unicode without copying two times the buffer - - Unicode equivalent of spprintf? - */ - length = spprintf(&value, 0, "%04u-%02u-%02u", t.year, t.month, t.day); + length = mnd_sprintf(&value, 0, "%04u-%02u-%02u", t.year, t.month, t.day); DBG_INF_FMT("%s", value); #if MYSQLND_UNICODE if (!as_unicode) { #endif ZVAL_STRINGL(zv, value, length, 1); - efree(value); /* allocated by spprintf */ + mnd_sprintf_free(value); #if MYSQLND_UNICODE } else { ZVAL_UTF8_STRINGL(zv, value, length, ZSTR_AUTOFREE); @@ -367,19 +359,14 @@ void ps_fetch_datetime(zval *zv, const MYSQLND_FIELD * t.time_type = MYSQLND_TIMESTAMP_DATETIME; } - /* - QQ : How to make this unicode without copying two times the buffer - - Unicode equivalent of spprintf? - */ - length = spprintf(&value, 0, "%04u-%02u-%02u %02u:%02u:%02u", - t.year, t.month, t.day, t.hour, t.minute, t.second); + length = mnd_sprintf(&value, 0, "%04u-%02u-%02u %02u:%02u:%02u", t.year, t.month, t.day, t.hour, t.minute, t.second); DBG_INF_FMT("%s", value); #if MYSQLND_UNICODE if (!as_unicode) { #endif ZVAL_STRINGL(zv, value, length, 1); - efree(value); /* allocated by spprintf */ + mnd_sprintf_free(value); #if MYSQLND_UNICODE } else { ZVAL_UTF8_STRINGL(zv, to, length, ZSTR_AUTOFREE); @@ -621,7 +608,7 @@ mysqlnd_stmt_execute_store_params(MYSQLND_STMT * s, ze *buf_len = offset + null_count + 20; tmp_buf = mnd_emalloc(*buf_len); if (!tmp_buf) { - SET_OOM_ERROR(stmt->error_info); + SET_OOM_ERROR(*stmt->error_info); goto end; } memcpy(tmp_buf, *buf, offset); @@ -655,7 +642,7 @@ mysqlnd_stmt_execute_store_params(MYSQLND_STMT * s, ze if (Z_TYPE_P(stmt->param_bind[i].zv) != IS_LONG && PASS != mysqlnd_stmt_copy_it(&copies, stmt->param_bind[i].zv, stmt->param_count, i TSRMLS_CC)) { - SET_OOM_ERROR(stmt->error_info); + SET_OOM_ERROR(*stmt->error_info); goto end; } /* @@ -683,7 +670,7 @@ mysqlnd_stmt_execute_store_params(MYSQLND_STMT * s, ze *buf_len = offset + stmt->param_count * 2 + 20; tmp_buf = mnd_emalloc(*buf_len); if (!tmp_buf) { - SET_OOM_ERROR(stmt->error_info); + SET_OOM_ERROR(*stmt->error_info); goto end; } memcpy(tmp_buf, *buf, offset); @@ -746,7 +733,7 @@ mysqlnd_stmt_execute_store_params(MYSQLND_STMT * s, ze /* Double binding of the same zval, make a copy */ if (!copies || !copies[i]) { if (PASS != mysqlnd_stmt_copy_it(&copies, the_var, stmt->param_count, i TSRMLS_CC)) { - SET_OOM_ERROR(stmt->error_info); + SET_OOM_ERROR(*stmt->error_info); goto end; } } @@ -760,7 +747,7 @@ mysqlnd_stmt_execute_store_params(MYSQLND_STMT * s, ze if (Z_TYPE_P(the_var) != IS_DOUBLE) { if (!copies || !copies[i]) { if (PASS != mysqlnd_stmt_copy_it(&copies, the_var, stmt->param_count, i TSRMLS_CC)) { - SET_OOM_ERROR(stmt->error_info); + SET_OOM_ERROR(*stmt->error_info); goto end; } } @@ -807,7 +794,7 @@ use_string: { if (!copies || !copies[i]) { if (PASS != mysqlnd_stmt_copy_it(&copies, the_var, stmt->param_count, i TSRMLS_CC)) { - SET_OOM_ERROR(stmt->error_info); + SET_OOM_ERROR(*stmt->error_info); goto end; } } @@ -832,7 +819,7 @@ use_string: *buf_len = offset + data_size + 10; /* Allocate + 10 for safety */ tmp_buf = mnd_emalloc(*buf_len); if (!tmp_buf) { - SET_OOM_ERROR(stmt->error_info); + SET_OOM_ERROR(*stmt->error_info); goto end; } memcpy(tmp_buf, *buf, offset);