|
|||||||||||
|
PHP mysqlnd svn commit: r942 - trunk/mysqlnd
From: <ahristov(at)mysql.com>
Date: Wed Aug 22 2007 - 13:59:12 EDT
Modified: trunk/mysqlnd/mysqlnd.c trunk/mysqlnd/mysqlnd_debug.c trunk/mysqlnd/mysqlnd_debug.h trunk/mysqlnd/mysqlnd_loaddata.c trunk/mysqlnd/mysqlnd_palloc.c trunk/mysqlnd/mysqlnd_ps.c trunk/mysqlnd/mysqlnd_ps_codec.c trunk/mysqlnd/mysqlnd_result.c trunk/mysqlnd/mysqlnd_result_meta.c trunk/mysqlnd/mysqlnd_wireprotocol.c Log: Enable tracing of memory allocations. One step is to enable mysqlnd to track the memory it has allocated and how many calls to different allocation functions have been performed. Modified: trunk/mysqlnd/mysqlnd.c
#ifdef ZTS
mysqlnd_global_stats->LOCK_access = tsrm_mutex_alloc();
tsrm_mutex_free(mysqlnd_global_stats->LOCK_access); #endif - free(mysqlnd_global_stats); + mnd_free(mysqlnd_global_stats); mysqlnd_global_stats = NULL; } mysqlnd_library_initted = FALSE; @@ -134,79 +134,87 @@
DBG_INF("Freeing memory of members");
if (conn->host) {
- pefree(conn->host, pers);
+ DBG_INF("Freeing host");
+ mnd_pefree(conn->host, pers);
conn->host = NULL;
}
if (conn->user) {
- pefree(conn->user, pers);
+ DBG_INF("Freeing user");
+ mnd_pefree(conn->user, pers);
conn->user = NULL;
}
if (conn->passwd) {
- pefree(conn->passwd, pers);
+ DBG_INF("Freeing passwd");
+ mnd_pefree(conn->passwd, pers);
conn->passwd = NULL;
}
if (conn->unix_socket) {
- pefree(conn->unix_socket, pers);
+ DBG_INF("Freeing unix_socket");
+ mnd_pefree(conn->unix_socket, pers);
conn->unix_socket = NULL;
}
if (conn->scheme) {
- pefree(conn->scheme, pers);
+ DBG_INF("Freeing scheme");
+ mnd_pefree(conn->scheme, pers);
conn->scheme = NULL;
}
if (conn->server_version) {
- pefree(conn->server_version, pers);
+ DBG_INF("Freeing server_version");
+ mnd_pefree(conn->server_version, pers);
conn->server_version = NULL;
}
if (conn->host_info) {
- pefree(conn->host_info, pers);
+ DBG_INF("Freeing host_info");
+ mnd_pefree(conn->host_info, pers);
conn->host_info = NULL;
}
if (conn->scramble) {
- pefree(conn->scramble, pers);
+ DBG_INF("Freeing scramble");
+ mnd_pefree(conn->scramble, pers);
conn->scramble = NULL;
}
if (conn->last_message) {
- pefree(conn->last_message, pers);
+ mnd_pefree(conn->last_message, pers);
conn->last_message = NULL;
}
if (conn->options.charset_name) {
- pefree(conn->options.charset_name, pers);
+ mnd_pefree(conn->options.charset_name, pers);
conn->options.charset_name = NULL;
}
if (conn->options.num_commands) {
unsigned int i;
for (i=0; i < conn->options.num_commands; i++) {
- pefree(conn->options.init_commands[i], pers);
+ mnd_pefree(conn->options.init_commands[i], pers);
}
- pefree(conn->options.init_commands, pers);
+ mnd_pefree(conn->options.init_commands, pers);
conn->options.init_commands = NULL;
}
if (conn->options.cfg_file) {
- pefree(conn->options.cfg_file, pers);
+ mnd_pefree(conn->options.cfg_file, pers);
conn->options.cfg_file = NULL;
}
if (conn->options.cfg_section) {
- pefree(conn->options.cfg_section, pers);
+ mnd_pefree(conn->options.cfg_section, pers);
conn->options.cfg_section = NULL;
}
if (conn->options.ssl_key) {
- pefree(conn->options.ssl_key, pers);
+ mnd_pefree(conn->options.ssl_key, pers);
conn->options.ssl_key = NULL;
}
if (conn->options.ssl_cert) {
- pefree(conn->options.ssl_cert, pers);
+ mnd_pefree(conn->options.ssl_cert, pers);
conn->options.ssl_cert = NULL;
}
if (conn->options.ssl_ca) {
- pefree(conn->options.ssl_ca, pers);
+ mnd_pefree(conn->options.ssl_ca, pers);
conn->options.ssl_ca = NULL;
}
if (conn->options.ssl_capath) {
- pefree(conn->options.ssl_capath, pers);
+ mnd_pefree(conn->options.ssl_capath, pers);
conn->options.ssl_capath = NULL;
}
if (conn->options.ssl_cipher) {
- pefree(conn->options.ssl_cipher, pers);
+ mnd_pefree(conn->options.ssl_cipher, pers);
conn->options.ssl_cipher = NULL;
}
if (conn->zval_cache) {
@@ -241,7 +249,7 @@ conn->m->free_contents(conn TSRMLS_CC);
DBG_VOID_RETURN;
MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_CONNECT_REUSED);
/* Free here what should not be seen by the next script */
if (conn->last_message) {
- pefree(conn->last_message, conn->persistent);
+ mnd_pefree(conn->last_message, conn->persistent);
conn->last_message = NULL;
}
} @@ -548,7 +556,7 @@
}
if (conn->persistent) {
conn->scheme = pestrndup(transport, transport_len, 1);
- efree(transport);
+ mnd_efree(transport);
} else {
conn->scheme = transport;
}
@@ -715,7 +723,7 @@
conn->zval_cache = mysqlnd_palloc_get_thd_cache_reference(zval_cache);
conn->net.cmd_buffer.length = 128L*1024L;
- conn->net.cmd_buffer.buffer = pemalloc(conn->net.cmd_buffer.length, conn->persistent);
+ conn->net.cmd_buffer.buffer = mnd_pemalloc(conn->net.cmd_buffer.length, conn->persistent);
MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_CONNECT_SUCCESS);
if (reconnect) {
@@ -747,10 +755,10 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, "[%d] %.64s (trying to connect via %s)", errcode, errstr, conn->scheme);
@@ -851,7 +859,7 @@ result->type = MYSQLND_RES_NORMAL; result->m.fetch_row = result->m.fetch_row_normal_unbuffered; - result->unbuf = ecalloc(1, sizeof(MYSQLND_RES_UNBUFFERED)); + result->unbuf = mnd_ecalloc(1, sizeof(MYSQLND_RES_UNBUFFERED)); result->unbuf->eof_reached = TRUE; DBG_RETURN(result); } @@ -1090,7 +1098,7 @@
} else {
conn->charset = charset;
}
- efree(query);
+ mnd_efree(query);
DBG_INF(ret == PASS? "PASS":"FAIL");
DBG_RETURN(ret);
@@ -1795,7 +1803,7 @@ /* {{{ mysqlnd_init */ PHPAPI MYSQLND *_mysqlnd_init(zend_bool persistent TSRMLS_DC) {
- MYSQLND *ret = pecalloc(1, sizeof(MYSQLND), persistent);
+ MYSQLND *ret = mnd_pecalloc(1, sizeof(MYSQLND), persistent);
DBG_ENTER("mysqlnd_init");
DBG_INF_FMT("persistent=%d", persistent);
Modified: trunk/mysqlnd/mysqlnd_debug.c
+
+void * _mysqlnd_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+{
+ void *ret;
+ TSRMLS_FETCH();
+ DBG_ENTER("mysqlnd_emalloc");
+ DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
+ DBG_INF_FMT("before: %lu", zend_memory_usage(FALSE TSRMLS_CC));
+ ret = emalloc(size);
+ DBG_INF_FMT("after : %lu", zend_memory_usage(FALSE TSRMLS_CC));
+ DBG_INF_FMT("size=%lu ptr=%p", size, ret);
+ DBG_RETURN(ret);
+}
+
+void * _mysqlnd_pemalloc(size_t size, zend_bool persistent ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+{
+ void *ret;
+ TSRMLS_FETCH();
+ DBG_ENTER("mysqlnd_pemalloc");
+ DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
+ DBG_INF_FMT("before: %lu", zend_memory_usage(persistent TSRMLS_CC));
+
+ ret = pemalloc(size, persistent);
+
+ DBG_INF_FMT("after : %lu", zend_memory_usage(persistent TSRMLS_CC));
+ DBG_INF_FMT("size=%lu ptr=%p persistent=%d", size, ret, persistent);
+ DBG_RETURN(ret);
+}
+
+void * _mysqlnd_ecalloc(uint nmemb, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+{
+ void *ret;
+ TSRMLS_FETCH();
+ DBG_ENTER("_mysqlnd_calloc");
+ DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
+ DBG_INF_FMT("before: %lu", zend_memory_usage(FALSE TSRMLS_CC));
+
+ ret = ecalloc(nmemb, size);
+
+ DBG_INF_FMT("after : %lu", zend_memory_usage(FALSE TSRMLS_CC));
+ DBG_INF_FMT("size=%lu ptr=%p", size, ret);
+ DBG_RETURN(ret);
+}
+
+void * _mysqlnd_pecalloc(uint nmemb, size_t size, zend_bool persistent ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+{
+ void *ret;
+ TSRMLS_FETCH();
+ DBG_ENTER("_mysqlnd_calloc");
+ DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
+ DBG_INF_FMT("before: %lu", zend_memory_usage(persistent TSRMLS_CC));
+
+ ret = pecalloc(nmemb, size, persistent);
+
+ DBG_INF_FMT("after : %lu", zend_memory_usage(persistent TSRMLS_CC));
+ DBG_INF_FMT("size=%lu ptr=%p", size, ret);
+ DBG_RETURN(ret);
+}
+
+void * _mysqlnd_erealloc(void *ptr, size_t new_size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+{
+ void *ret;
+ TSRMLS_FETCH();
+ DBG_ENTER("mysqlnd_erealloc");
+ DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
+ DBG_INF_FMT("ptr=%p new_size=%lu", ptr, new_size);
+ DBG_INF_FMT("before: %lu", zend_memory_usage(FALSE TSRMLS_CC));
+
+ ret = erealloc(ptr, new_size);
+
+ DBG_INF_FMT("after : %lu", zend_memory_usage(FALSE TSRMLS_CC));
+ DBG_INF_FMT("new_ptr=%p", ret);
+ DBG_RETURN(ret);
+}
+
+void * _mysqlnd_perealloc(void *ptr, size_t new_size, zend_bool persistent ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+{
+ void *ret;
+ TSRMLS_FETCH();
+ DBG_ENTER("mysqlnd_erealloc");
+ DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
+ DBG_INF_FMT("ptr=%p new_size=%lu persist=%d", ptr, new_size, persistent);
+ DBG_INF_FMT("before: %lu", zend_memory_usage(persistent TSRMLS_CC));
+
+ ret = perealloc(ptr, new_size, persistent);
+
+ DBG_INF_FMT("after : %lu", zend_memory_usage(persistent TSRMLS_CC));
+ DBG_INF_FMT("new_ptr=%p", ret);
+ DBG_RETURN(ret);
+}
+
+void _mysqlnd_efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+{
+ TSRMLS_FETCH();
+ DBG_ENTER("mysqlnd_efree");
+ DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
+ DBG_INF_FMT("ptr=%p", ptr);
+ DBG_INF_FMT("before: %lu", zend_memory_usage(FALSE TSRMLS_CC));
+
+ efree(ptr);
+
+ DBG_INF_FMT("after : %lu", zend_memory_usage(FALSE TSRMLS_CC));
+ DBG_VOID_RETURN;
+}
+
+void _mysqlnd_pefree(void *ptr, zend_bool persistent ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+{
+ TSRMLS_FETCH();
+ DBG_ENTER("mysqlnd_efree");
+ DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
+ DBG_INF_FMT("ptr=%p persistent=%d", ptr, persistent);
+ DBG_INF_FMT("before: %lu", zend_memory_usage(persistent TSRMLS_CC));
+
+ pefree(ptr, persistent);
+
+ DBG_INF_FMT("after : %lu", zend_memory_usage(persistent TSRMLS_CC));
+ DBG_VOID_RETURN;
+}
+
+
+void * _mysqlnd_malloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+{
+ void *ret;
+ TSRMLS_FETCH();
+ DBG_ENTER("mysqlnd_malloc");
+ DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
+ DBG_INF_FMT("before: %lu", zend_memory_usage(TRUE TSRMLS_CC));
+
+ ret = malloc(size);
+
+ DBG_INF_FMT("after : %lu", zend_memory_usage(TRUE TSRMLS_CC));
+ DBG_INF_FMT("size=%lu ptr=%p", size, ret);
+ DBG_RETURN(ret);
+}
+
+void * _mysqlnd_calloc(uint nmemb, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+{
+ void *ret;
+ TSRMLS_FETCH();
+ DBG_ENTER("_mysqlnd_calloc");
+ DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
+ DBG_INF_FMT("before: %lu", zend_memory_usage(TRUE TSRMLS_CC));
+
+ ret = calloc(nmemb, size);
+
+ DBG_INF_FMT("after : %lu", zend_memory_usage(TRUE TSRMLS_CC));
+ DBG_INF_FMT("size=%lu ptr=%p", size, ret);
+ DBG_RETURN(ret);
+}
+
+
+void * _mysqlnd_realloc(void *ptr, size_t new_size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+{
+ void *ret;
+ TSRMLS_FETCH();
+ DBG_ENTER("mysqlnd_realloc");
+ DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
+ DBG_INF_FMT("ptr=%p new_size=%lu ", new_size, ptr);
+ DBG_INF_FMT("before: %lu", zend_memory_usage(TRUE TSRMLS_CC));
+
+ ret = realloc(ptr, new_size);
+
+ DBG_INF_FMT("after : %lu", zend_memory_usage(TRUE TSRMLS_CC));
+ DBG_INF_FMT("new_ptr=%p", ret);
+ DBG_RETURN(ret);
+}
+
+void _mysqlnd_free(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+{
+ TSRMLS_FETCH();
+ DBG_ENTER("mysqlnd_free");
+ DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
+ DBG_INF_FMT("ptr=%p", ptr);
+ DBG_INF_FMT("before: %lu", zend_memory_usage(TRUE TSRMLS_CC));
+
+ free(ptr);
+
+ DBG_INF_FMT("after : %lu", zend_memory_usage(TRUE TSRMLS_CC));
+ DBG_VOID_RETURN;
+}
+
+
/*
Modified: trunk/mysqlnd/mysqlnd_debug.h
#include "zend_stack.h"
+#define MYSQLND_DEBUG_MEMORY 0
enum_func_status (*open)(MYSQLND_DEBUG *self, zend_bool reopen);
MYSQLND_DEBUG *mysqlnd_debug_init(TSRMLS_D); + +void * _mysqlnd_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); +void * _mysqlnd_pemalloc(size_t size, zend_bool persistent ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); +void * _mysqlnd_ecalloc(uint nmemb, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); +void * _mysqlnd_pecalloc(uint nmemb, size_t size, zend_bool persistent ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); +void * _mysqlnd_erealloc(void *ptr, size_t new_size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); +void * _mysqlnd_perealloc(void *ptr, size_t new_size, zend_bool persistent ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); +void _mysqlnd_efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); +void _mysqlnd_pefree(void *ptr, zend_bool persistent ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); +void * _mysqlnd_malloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); +void * _mysqlnd_calloc(uint nmemb, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); +void * _mysqlnd_realloc(void *ptr, size_t new_size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); +void _mysqlnd_free(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); + #if PHP_DEBUG && !defined(PHP_WIN32) #define DBG_INF(msg) do { if(MYSQLND_G(dbg)) MYSQLND_G(dbg)->m->log(MYSQLND_G(dbg), __LINE__, __FILE__, -1, "info : ", (msg)); } while (0) #define DBG_ERR(msg) do { if(MYSQLND_G(dbg)) MYSQLND_G(dbg)->m->log(MYSQLND_G(dbg), __LINE__, __FILE__, -1, "error: ", (msg)); } while (0) @@ -67,6 +83,8 @@
#define DBG_RETURN(value) do { if(MYSQLND_G(dbg)) MYSQLND_G(dbg)->m->func_leave(MYSQLND_G(dbg), __LINE__, __FILE__); return (value); } while (0)
#define DBG_VOID_RETURN do { if(MYSQLND_G(dbg)) MYSQLND_G(dbg)->m->func_leave(MYSQLND_G(dbg), __LINE__, __FILE__); return; } while (0)
+
#else #define DBG_INF(msg) #define DBG_ERR(msg) +#endif +#if MYSQLND_DEBUG_MEMORY + +#define mnd_emalloc(size) _mysqlnd_emalloc((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) +#define mnd_pemalloc(size, pers) _mysqlnd_pemalloc((size), (pers) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) +#define mnd_ecalloc(nmemb, size) _mysqlnd_ecalloc((nmemb), (size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) +#define mnd_pecalloc(nmemb, size, p) _mysqlnd_pecalloc((nmemb), (size), (p) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) +#define mnd_erealloc(ptr, new_size) _mysqlnd_erealloc((ptr), (new_size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) +#define mnd_perealloc(ptr, new_size, p) _mysqlnd_perealloc((ptr), (new_size), (p) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) +#define mnd_efree(ptr) _mysqlnd_efree((ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) +#define mnd_pefree(ptr, pers) _mysqlnd_pefree((ptr), (pers) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) +#define mnd_malloc(size) _mysqlnd_malloc((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) +#define mnd_calloc(nmemb, size) _mysqlnd_calloc((nmemb), (size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) +#define mnd_realloc(ptr, new_size) _mysqlnd_realloc((ptr), (new_size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) +#define mnd_free(ptr) _mysqlnd_free((ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) + +#else + +#define mnd_emalloc(size) emalloc((size)) +#define mnd_pemalloc(size, pers) pemalloc((size), (pers)) +#define mnd_ecalloc(nmemb, size) ecalloc((nmemb), (size)) +#define mnd_pecalloc(nmemb, size, p) pecalloc((nmemb), (size), (p)) +#define mnd_erealloc(ptr, new_size) erealloc((ptr), (new_size)) +#define mnd_perealloc(ptr, new_size, p) perealloc((ptr), (new_size), (p)) +#define mnd_efree(ptr) efree((ptr)) +#define mnd_pefree(ptr, pers) pefree((ptr), (pers)) +#define mnd_malloc(size) malloc((size)) +#define mnd_calloc(nmemb, size) calloc((nmemb), (size)) +#define mnd_realloc(ptr, new_size) realloc((ptr), (new_size)) +#define mnd_free(ptr) free((ptr)) + #endif #endif /* MYSQLND_DEBUG_H */ Modified: trunk/mysqlnd/mysqlnd_loaddata.c
enum_func_status mysqlnd_simple_command_handle_response(MYSQLND *conn,
enum php_mysql_packet_type ok_packet,
a = (zval ***)safe_emalloc(c, sizeof(zval **), 0);\
for (i = b; i < c; i++) {\
- a[i] = emalloc(sizeof(zval *));\
+ a[i] = mnd_emalloc(sizeof(zval *));\
MAKE_STD_ZVAL(*a[i]);\
}\
} @@ -43,9 +44,9 @@ if (a) {\
for (i=b; i < c; i++) {\
zval_ptr_dtor(a[i]);\
- efree(a[i]);\
+ mnd_efree(a[i]);\
}\
- efree(a);\
+ mnd_efree(a);\
}
/* {{{ mysqlnd_local_infile_init */
MYSQLND_INFILE_INFO *info;
php_stream_context *context = NULL;
- *ptr= info= ((MYSQLND_INFILE_INFO *)ecalloc(1, sizeof(MYSQLND_INFILE_INFO)));
+ *ptr= info= ((MYSQLND_INFILE_INFO *)mnd_ecalloc(1, sizeof(MYSQLND_INFILE_INFO)));
/* check open_basedir */
if (PG(open_basedir)) {
} /* }}} */ @@ -261,7 +262,7 @@ infile = conn->infile; /* allocate buffer for reading data */ - buf = (char *)ecalloc(1, buflen); + buf = (char *)mnd_ecalloc(1, buflen); *is_warning = FALSE; } /* }}} */ Modified: trunk/mysqlnd/mysqlnd_palloc.c
/* Data in pointed by 'block' was cleaned in RSHUTDOWN */ - free(cache->block); - free(cache->free_list.ptr_line); - free(cache); + mnd_free(cache->block); + mnd_free(cache->free_list.ptr_line); + mnd_free(cache); } /* }}} */ @@ -176,8 +176,8 @@ php_printf("[mysqlnd_palloc_free_thd_cache %p]\n", cache); #endif
@@ -291,7 +291,7 @@ void *ret = NULL;
DBG_ENTER("mysqlnd_palloc_get_zval");
- DBG_INF_FMT("cache=%p *last_added=%p free_items=%d\n",
+ DBG_INF_FMT("cache=%p *last_added=%p free_items=%d",
thd_cache, thd_cache? thd_cache->parent->free_list.last_added:NULL,
thd_cache->parent->free_items);
Modified: trunk/mysqlnd/mysqlnd_ps.c
/* Now we will have a clean new statement object */
- efree(stmt_to_prepare);
+ mnd_efree(stmt_to_prepare);
}
stmt->state = MYSQLND_STMT_PREPARED;
DBG_INF("PASS");
@@ -1044,7 +1044,7 @@
if (conn->state == CONN_READY) {
stmt->param_bind[param_no].flags |= MYSQLND_PARAM_BIND_BLOB_USED;
- cmd_buf = emalloc(packet_len = STMT_ID_LENGTH + 2 + length);
+ cmd_buf = mnd_emalloc(packet_len = STMT_ID_LENGTH + 2 + length);
int4store(cmd_buf, stmt->stmt_id);
int2store(cmd_buf + STMT_ID_LENGTH, param_no);
@@ -1691,7 +1691,7 @@ /* {{{ _mysqlnd_stmt_init */ MYSQLND_STMT * _mysqlnd_stmt_init(MYSQLND * const conn TSRMLS_DC) {
- MYSQLND_STMT *stmt = ecalloc(1, sizeof(MYSQLND_STMT));
+ MYSQLND_STMT *stmt = mnd_ecalloc(1, sizeof(MYSQLND_STMT));
DBG_ENTER("_mysqlnd_stmt_init");
DBG_INF_FMT("stmt=%p", stmt);
Modified: trunk/mysqlnd/mysqlnd_ps_codec.c
-
@@ -205,7 +205,7 @@
if (uval > INT_MAX) {
char *tmp, *p;
int j=10;
- tmp= emalloc(11);
+ tmp= mnd_emalloc(11);
p= &tmp[9];
do {
*p-- = (uval % 10) + 48;
Modified: trunk/mysqlnd/mysqlnd_result.c
DBG_ENTER("mysqlnd_free_buffered_data");
+ DBG_INF_FMT("Freeing "MYSQLND_LLU_SPEC" row(s)", result->data->row_count);
+ DBG_INF_FMT("before: real_usage=%lu usage=%lu", zend_memory_usage(TRUE TSRMLS_CC), zend_memory_usage(FALSE TSRMLS_CC));
for (row = 0; row < result->data->row_count; row++) {
unsigned int col;
zval **current_row = current_row = set->data[row];
} /* }}} */ @@ -154,6 +161,7 @@ result->m.free_result_buffers(result TSRMLS_CC);
if (result->row_packet) {
+ DBG_INF("Freeing packet");
PACKET_FREE(result->row_packet);
result->row_packet = NULL;
}
@@ -727,9 +736,9 @@ free_rows = next_extend;
conn->state = CONN_FETCHING_DATA;
ret = mysqlnd_store_result_fetch_data(conn, result, result->meta, ps_protocol, TRUE, to_cache TSRMLS_CC); @@ -1127,7 +1136,7 @@ /* {{{ mysqlnd_result_init */ MYSQLND_RES *mysqlnd_result_init(unsigned int field_count, MYSQLND_THD_ZVAL_PCACHE *cache TSRMLS_DC) {
- MYSQLND_RES *ret = ecalloc(1, sizeof(MYSQLND_RES));
+ MYSQLND_RES *ret = mnd_ecalloc(1, sizeof(MYSQLND_RES));
DBG_ENTER("mysqlnd_result_init");
DBG_INF_FMT("field_count=%u cache=%p", field_count, cache);
Modified: trunk/mysqlnd/mysqlnd_result_meta.c
/* {{{ php_mysqlnd_free_field_metadata */
static
if (meta) {
if (meta->root) {
- pefree(meta->root, persistent);
+ DBG_INF("Freeing field metadata root");
+ mnd_pefree(meta->root, persistent);
meta->root = NULL;
}
if (meta->def) {
- pefree(meta->def, persistent);
+ DBG_INF("Freeing field def");
+ mnd_pefree(meta->def, persistent);
meta->def = NULL;
}
}
@@ -152,7 +154,7 @@
if (meta->fields[i].root) {
/* We re-read metadata for PS */
- efree(meta->fields[i].root);
+ mnd_efree(meta->fields[i].root);
meta->fields[i].root = NULL;
}
} @@ -299,15 +304,15 @@ { unsigned int i; /* +1 is to have empty marker at the end */ - MYSQLND_RES_METADATA *new_meta = pemalloc(sizeof(MYSQLND_RES_METADATA), persistent); - MYSQLND_FIELD *new_fields = pecalloc(meta->field_count + 1, sizeof(MYSQLND_FIELD), persistent); + MYSQLND_RES_METADATA *new_meta = mnd_pemalloc(sizeof(MYSQLND_RES_METADATA), persistent); + MYSQLND_FIELD *new_fields = mnd_pecalloc(meta->field_count + 1, sizeof(MYSQLND_FIELD), persistent); MYSQLND_FIELD *orig_fields = meta->fields; size_t len = meta->field_count * sizeof(struct mysqlnd_field_hash_key); DBG_ENTER("mysqlnd_res_meta::clone_metadata"); DBG_INF_FMT("persistent=%d", persistent); - new_meta->zend_hash_keys = pemalloc(len, persistent); + new_meta->zend_hash_keys = mnd_pemalloc(len, persistent); memcpy(new_meta->zend_hash_keys, meta->zend_hash_keys, len); new_meta->m = meta->m; Modified: trunk/mysqlnd/mysqlnd_wireprotocol.c
int1store(p, packet->command);
ret = mysqlnd_stream_write_w_header(conn, (char *)tmp, tmp_len - MYSQLND_HEADER_SIZE TSRMLS_CC);
if (tmp != net->cmd_buffer.buffer) {
MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_CMD_BUFFER_TOO_SMALL);
- efree(tmp);
+ mnd_efree(tmp);
}
written = ret;
#endif @@ -939,7 +939,7 @@ void php_mysqlnd_cmd_free_mem(void *_packet, zend_bool alloca) {
if (!alloca) {
- efree((php_mysql_packet_command *) _packet);
+ mnd_efree((php_mysql_packet_command *) _packet);
}
} /* }}} */ @@ -981,7 +981,7 @@ Thus, the name is size - 1. And we add 1 for a trailing \0. */ len = packet->header.size - 1; - packet->info_or_local_file = pemalloc(len + 1, conn->persistent); + packet->info_or_local_file = mnd_pemalloc(len + 1, conn->persistent); memcpy(packet->info_or_local_file, p, len); packet->info_or_local_file[len] = '\0'; packet->info_or_local_file_len = len; @@ -1022,11 +1022,11 @@ {
php_mysql_packet_rset_header *p= (php_mysql_packet_rset_header *) _packet;
if (p->info_or_local_file) {
- efree(p->info_or_local_file);
+ mnd_efree(p->info_or_local_file);
p->info_or_local_file = NULL;
}
if (!alloca) {
- efree(p);
+ mnd_efree(p);
}
} /* }}} */ @@ -1137,7 +1137,7 @@
len != MYSQLND_NULL_LENGTH)
{
DBG_INF_FMT("Def found, length %lu", len);
- meta->def = emalloc(len + 1);
+ meta->def = mnd_emalloc(len + 1);
memcpy(meta->def, p, len);
meta->def[len] = '\0';
meta->def_length = len;
@@ -1216,7 +1216,7 @@
/* p->metadata was passed to us as temporal buffer */
if (!alloca) {
- efree(p);
+ mnd_efree(p);
}
} /* }}} */ @@ -1258,7 +1258,7 @@
We need a trailing \0 for the last string, in case of text-mode,
to be able to implement read-only variables. Thus, we add + 1.
*/
- p = new_buf = pemalloc(*data_size + 1, persistent_alloc);
+ p = new_buf = mnd_pemalloc(*data_size + 1, persistent_alloc);
net->stream->chunk_size = header.size;
} else if (!first_iteration) {
/* Empty packet after MYSQLND_MAX_PACKET_SIZE packet. That's ok, break */
@@ -1655,7 +1655,7 @@ php_mysql_packet_row *p= (php_mysql_packet_row *) _packet; if (p->row_buffer) { - pefree(p->row_buffer, p->persistent_alloc); + mnd_pefree(p->row_buffer, p->persistent_alloc); p->row_buffer = NULL; } /* } /* }}} */ @@ -1684,7 +1684,7 @@ PACKET_READ_HEADER_AND_BODY(packet, conn, buf, sizeof(buf), "statistics");
-- MySQL Code Commits Mailing List For list archives: http://lists.mysql.com/commits To unsubscribe: http://lists.mysql.com/commits?unsub=lists@pantek.comReceived on Wed Aug 22 14:00:11 2007 This archive was generated by hypermail 2.1.8 : Sun Oct 07 2007 - 08:43:05 EDT |
||||||||||
|
|||||||||||