summaryrefslogtreecommitdiff
path: root/ext/mysqlnd/mysqlnd_statistics.c
diff options
context:
space:
mode:
authorAndrey Hristov <andrey@php.net>2010-01-11 14:27:35 +0000
committerAndrey Hristov <andrey@php.net>2010-01-11 14:27:35 +0000
commit41ead37c041fe676a3f201d78d4761a213c322e8 (patch)
treeb3e2e4bf3facc579338bb349f235a6c09c786fe5 /ext/mysqlnd/mysqlnd_statistics.c
parent7669d7681a9036b52e440c1a43ee67ed61b10eb2 (diff)
downloadphp-git-41ead37c041fe676a3f201d78d4761a213c322e8.tar.gz
Rework the statistics macros to be reusable by external entities.
Rename handlers to triggers. Dynamically allocate space for the statistics thus allow reusability.
Diffstat (limited to 'ext/mysqlnd/mysqlnd_statistics.c')
-rw-r--r--ext/mysqlnd/mysqlnd_statistics.c7
1 files changed, 5 insertions, 2 deletions
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);
}