From 9b8d026d86341829e1f18cfdc581ab1ab8655ce2 Mon Sep 17 00:00:00 2001 From: Andrey Hristov Date: Mon, 11 Jan 2010 14:27:35 +0000 Subject: Rework the statistics macros to be reusable by external entities. Rename handlers to triggers. Dynamically allocate space for the statistics thus allow reusability. --- ext/mysqlnd/mysqlnd_statistics.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'ext/mysqlnd/mysqlnd_statistics.c') diff --git a/ext/mysqlnd/mysqlnd_statistics.c b/ext/mysqlnd/mysqlnd_statistics.c index 50eba8cfcd..756d4ce228 100644 --- a/ext/mysqlnd/mysqlnd_statistics.c +++ b/ext/mysqlnd/mysqlnd_statistics.c @@ -237,11 +237,13 @@ PHPAPI void _mysqlnd_get_client_stats(zval *return_value TSRMLS_DC ZEND_FILE_LIN /* {{{ mysqlnd_stats_init */ PHPAPI void -mysqlnd_stats_init(MYSQLND_STATS ** stats) +mysqlnd_stats_init(MYSQLND_STATS ** stats, size_t statistic_count) { *stats = calloc(1, sizeof(MYSQLND_STATS)); - (*stats)->triggers = calloc(STAT_LAST, sizeof(mysqlnd_stat_trigger)); + (*stats)->values = calloc(statistic_count, sizeof(uint64_t)); + (*stats)->triggers = calloc(statistic_count, sizeof(mysqlnd_stat_trigger)); (*stats)->in_trigger = FALSE; + (*stats)->count = statistic_count; #ifdef ZTS (*stats)->LOCK_access = tsrm_mutex_alloc(); #endif @@ -258,6 +260,7 @@ mysqlnd_stats_end(MYSQLND_STATS * stats) tsrm_mutex_free(stats->LOCK_access); #endif free(stats->triggers); + free(stats->values); /* mnd_free will reference LOCK_access and crash...*/ free(stats); } -- cgit v1.2.1