Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

PHP mysqlnd svn commit: r942 - trunk/mysqlnd

From: <ahristov(at)mysql.com>
Date: Wed Aug 22 2007 - 13:59:12 EDT


Author: ahristov
Date: 2007-08-22 19:59:11 +0200 (Wed, 22 Aug 2007) New Revision: 942

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


  • trunk/mysqlnd/mysqlnd.c 2007-08-22 14:59:54 UTC (rev 941) +++ trunk/mysqlnd/mysqlnd.c 2007-08-22 17:59:11 UTC (rev 942)
    @@ -77,7 +77,7 @@
    mysqlnd_library_initted = TRUE; _mysqlnd_init_ps_subsystem(); if (collect_statistics) { - mysqlnd_global_stats = calloc(1, sizeof(MYSQLND_STATS)); + mysqlnd_global_stats = mnd_calloc(1, sizeof(MYSQLND_STATS));

 #ifdef ZTS

                         mysqlnd_global_stats->LOCK_access = tsrm_mutex_alloc();
@@ -97,7 +97,7 @@

 #ifdef ZTS

                         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;

@@ -117,7 +117,7 @@
mysqlnd_local_infile_default(conn, TRUE); if (conn->current_result) { conn->current_result->m.free_result_contents(conn->current_result TSRMLS_CC); - efree(conn->current_result); + mnd_efree(conn->current_result); conn->current_result = NULL; }

@@ -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");
Do you need help?X
+ 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);
Do you need more help?X
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) {
@@ -221,7 +229,7 @@
} if (conn->net.cmd_buffer.buffer) { DBG_INF("Freeing cmd buffer"); - pefree(conn->net.cmd_buffer.buffer, pers); + mnd_pefree(conn->net.cmd_buffer.buffer, pers); conn->net.cmd_buffer.buffer = NULL; } conn->charset = NULL;

@@ -241,7 +249,7 @@
 

         conn->m->free_contents(conn TSRMLS_CC);  

  • pefree(conn, conn->persistent); + mnd_pefree(conn, conn->persistent);
Can we help you?X

         DBG_VOID_RETURN;
 }
@@ -430,7 +438,7 @@

 	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;
 	}

@@ -582,7 +590,7 @@
/* Shut-up the streams, they don't know what they are doing */ conn->net.stream->__exposed = 1; #endif - efree(hashed_details); + mnd_efree(hashed_details); } if (errstr || !conn->net.stream) {
@@ -648,7 +656,7 @@
auth_packet->max_packet_size= 3UL*1024UL*1024UL*1024UL; auth_packet->client_flags= mysql_flags; - conn->scramble = auth_packet->server_scramble_buf = pemalloc(SCRAMBLE_LENGTH, conn->persistent); + conn->scramble = auth_packet->server_scramble_buf = mnd_pemalloc(SCRAMBLE_LENGTH, conn->persistent); memcpy(auth_packet->server_scramble_buf, greet_packet.scramble_buf, SCRAMBLE_LENGTH); if (!PACKET_WRITE(auth_packet, conn)) { conn->state = CONN_QUIT_SENT;
@@ -687,7 +695,7 @@
spprintf(&p, 0, "MySQL host info: %s via TCP/IP", conn->host); if (conn->persistent) { conn->host_info = pestrdup(p, 1);
Can't find what you're looking for?X
- efree(p); + mnd_efree(p); } else { conn->host_info = p; }

@@ -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);  

  • efree(errstr); + mnd_efree(errstr); } if (conn->scheme) {
  • pefree(conn->scheme, conn->persistent); + mnd_pefree(conn->scheme, conn->persistent); conn->scheme = NULL; }

@@ -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);

@@ -889,7 +897,7 @@
result = conn->m->store_result(conn TSRMLS_CC); } if (show_query != query) { - efree(show_query); + mnd_efree(show_query); } 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);

@@ -1551,12 +1559,12 @@
} } if (ret == PASS) { - pefree(conn->user, conn->persistent); + mnd_pefree(conn->user, conn->persistent); conn->user = pestrndup(user, user_len, conn->persistent); - pefree(conn->passwd, conn->persistent); + mnd_pefree(conn->passwd, conn->persistent); conn->passwd = pestrdup(passwd, conn->persistent); if (conn->last_message) { - pefree(conn->last_message, conn->persistent); + mnd_pefree(conn->last_message, conn->persistent); conn->last_message = NULL; } conn->charset = conn->greet_charset;

@@ -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);
Don't know where to look next?X

@@ -1848,7 +1856,7 @@
php_info_print_table_row(2, s, Z_STRVAL_PP(values_entry)); } if (s) { - efree(s); + mnd_efree(s); } } else { php_info_print_table_row(2, string_key.s, Z_STRVAL_PP(values_entry));

Modified: trunk/mysqlnd/mysqlnd_debug.c


  • trunk/mysqlnd/mysqlnd_debug.c 2007-08-22 14:59:54 UTC (rev 941) +++ trunk/mysqlnd/mysqlnd_debug.c 2007-08-22 17:59:11 UTC (rev 942)
    @@ -432,6 +432,188 @@
    #endif }
+
+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)
Confused? Frustrated?X
+{ + 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);
Call Pantek today for Open Source Technical Support at 1-877-546-8934 - 24/7/365X
+ 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)
Do you need help?X
+{ + 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; +} + + /*
  • Local variables:
  • tab-width: 4

Modified: trunk/mysqlnd/mysqlnd_debug.h


  • trunk/mysqlnd/mysqlnd_debug.h 2007-08-22 14:59:54 UTC (rev 941) +++ trunk/mysqlnd/mysqlnd_debug.h 2007-08-22 17:59:11 UTC (rev 942)
    @@ -25,6 +25,8 @@

 #include "zend_stack.h"  

+#define MYSQLND_DEBUG_MEMORY 0
+
 struct st_mysqlnd_debug_methods
 {

         enum_func_status (*open)(MYSQLND_DEBUG *self, zend_bool reopen);
@@ -57,6 +59,20 @@
 

Do you need more help?X

 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);
Can we help you?X
+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)

@@ -77,7 +95,38 @@
#define DBG_RETURN(value) return (value) #define DBG_VOID_RETURN return;

+#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)
Can't find what you're looking for?X
+#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


  • trunk/mysqlnd/mysqlnd_loaddata.c 2007-08-22 14:59:54 UTC (rev 941) +++ trunk/mysqlnd/mysqlnd_loaddata.c 2007-08-22 17:59:11 UTC (rev 942)
    @@ -23,6 +23,7 @@
    #include "mysqlnd.h" #include "mysqlnd_wireprotocol.h" #include "mysqlnd_priv.h" +#include "mysqlnd_debug.h"

 enum_func_status mysqlnd_simple_command_handle_response(MYSQLND *conn,

                                                                                 enum php_mysql_packet_type ok_packet,
@@ -34,7 +35,7 @@

 if (c) {\

 	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 */
@@ -55,7 +56,7 @@

 	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)) {

@@ -157,7 +158,7 @@
rc = -1; } - efree(fp); + mnd_efree(fp); FREE_CALLBACK_ARGS(callback_args, 1, argc); return rc;
@@ -195,7 +196,7 @@
if (info->fd) { php_stream_close(info->fd); }
Confused? Frustrated?X
- efree(info); + mnd_efree(info); }

 }
 /* }}} */
@@ -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;
 

@@ -319,7 +320,7 @@
} (*conn->infile.local_infile_end)(info TSRMLS_CC); - efree(buf); + mnd_efree(buf); return result;

 }
 /* }}} */
Don't know where to look next?X

Modified: trunk/mysqlnd/mysqlnd_palloc.c


  • trunk/mysqlnd/mysqlnd_palloc.c 2007-08-22 14:59:54 UTC (rev 941) +++ trunk/mysqlnd/mysqlnd_palloc.c 2007-08-22 17:59:11 UTC (rev 942)
    @@ -117,9 +117,9 @@
    #endif
 	/* 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  

  • free(cache->gc_list.ptr_line);
  • free(cache); + mnd_free(cache->gc_list.ptr_line); + mnd_free(cache); } /* }}} */

@@ -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


  • trunk/mysqlnd/mysqlnd_ps.c 2007-08-22 14:59:54 UTC (rev 941) +++ trunk/mysqlnd/mysqlnd_ps.c 2007-08-22 17:59:11 UTC (rev 942)
    @@ -123,7 +123,7 @@
    } else { conn->error_info = result->data->error_info; stmt->result->m.free_result_contents(stmt->result TSRMLS_CC); - efree(stmt->result); + mnd_efree(stmt->result); stmt->result = NULL; stmt->state = MYSQLND_STMT_PREPARED; }
    @@ -261,7 +261,7 @@
    if (FAIL == (ret = PACKET_READ_ALLOCA(fields_eof, stmt->conn))) { if (stmt->result) { stmt->result->m.free_result_contents(stmt->result TSRMLS_CC); - efree(stmt->result); + mnd_efree(stmt->result); memset(stmt, 0, sizeof(MYSQLND_STMT)); stmt->state = MYSQLND_STMT_INITTED; }
    @@ -352,7 +352,7 @@
    memcpy(stmt, stmt_to_prepare, sizeof(MYSQLND_STMT));
 		/* 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");

@@ -442,7 +442,7 @@
FALSE TSRMLS_CC); if (free_request) { - efree(request); + mnd_efree(request); } if (ret == FAIL) {
@@ -670,7 +670,7 @@
the bound variables. Thus we need to do part of what it does or Zend will report leaks. */ - efree(row_packet->row_buffer); + mnd_efree(row_packet->row_buffer); row_packet->row_buffer = NULL; } } else if (ret == FAIL) {
@@ -738,7 +738,7 @@
result->m.fetch_lengths = NULL; /* makes no sense */ result->zval_cache = mysqlnd_palloc_get_thd_cache_reference(conn->zval_cache); - result->unbuf = ecalloc(1, sizeof(MYSQLND_RES_UNBUFFERED)); + result->unbuf = mnd_ecalloc(1, sizeof(MYSQLND_RES_UNBUFFERED)); DBG_INF_FMT("cursor=%d zval_cache=%p", stmt->cursor_exists, result->zval_cache); /*
@@ -848,7 +848,7 @@
/* We asked for one row, the next one should be EOF, eat it */ ret = PACKET_READ(row_packet, result->conn);
Call Pantek today for Open Source Technical Support at 1-877-546-8934 - 24/7/365X
if (row_packet->row_buffer) { - efree(row_packet->row_buffer); + mnd_efree(row_packet->row_buffer); row_packet->row_buffer = NULL; } } else {

@@ -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);

@@ -1053,7 +1053,7 @@
/* COM_STMT_SEND_LONG_DATA doesn't send an OK packet*/ ret = mysqlnd_simple_command(conn, cmd, (char *)cmd_buf, packet_len, PROT_LAST , FALSE TSRMLS_CC); - efree(cmd_buf); + mnd_efree(cmd_buf); if (FAIL == ret) { stmt->error_info = conn->error_info; }
@@ -1137,7 +1137,7 @@
stmt->param_bind[i].zv = NULL; } } - efree(stmt->param_bind); + mnd_efree(stmt->param_bind); } stmt->param_bind = param_bind;
@@ -1177,7 +1177,7 @@
if (stmt->state < MYSQLND_STMT_PREPARED) { SET_STMT_ERROR(stmt, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared); if (result_bind) { - efree(result_bind); + mnd_efree(result_bind); } DBG_ERR("not prepared"); DBG_RETURN(FAIL);
@@ -1203,7 +1203,7 @@
stmt->result_bind[i].bound = TRUE; } } else if (result_bind) { - efree(result_bind); + mnd_efree(result_bind); } DBG_INF("PASS"); DBG_RETURN(PASS);
@@ -1342,7 +1342,7 @@
result = mysqlnd_result_init(stmt->field_count, NULL TSRMLS_CC); 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; result->meta = stmt->result->meta->m->clone_metadata(stmt->result->meta, FALSE TSRMLS_CC);
Do you need help?X

@@ -1514,7 +1514,7 @@
} } } - efree(stmt->result_bind); + mnd_efree(stmt->result_bind); stmt->result_bind = NULL; DBG_VOID_RETURN;
@@ -1545,7 +1545,7 @@
} } - efree(stmt->param_bind); + mnd_efree(stmt->param_bind); stmt->param_bind = NULL; }
@@ -1560,7 +1560,7 @@
stmt->result = NULL; } if (stmt->cmd_buffer.buffer) { - efree(stmt->cmd_buffer.buffer); + mnd_efree(stmt->cmd_buffer.buffer); stmt->cmd_buffer.buffer = NULL; }
@@ -1641,7 +1641,7 @@
STAT_STMT_CLOSE_EXPLICIT); if (PASS == (ret = stmt->m->close(stmt, implicit TSRMLS_CC))) { - efree(stmt); + mnd_efree(stmt); } DBG_INF(ret == PASS? "PASS":"FAIL");

@@ -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); 

@@ -1699,7 +1699,7 @@
stmt->m = &mysqlnd_stmt_methods; stmt->state = MYSQLND_STMT_INITTED; stmt->cmd_buffer.length = 4096; - stmt->cmd_buffer.buffer = emalloc(stmt->cmd_buffer.length); + stmt->cmd_buffer.buffer = mnd_emalloc(stmt->cmd_buffer.length); stmt->prefetch_rows = MYSQLND_DEFAULT_PREFETCH_ROWS; /*

Modified: trunk/mysqlnd/mysqlnd_ps_codec.c


  • trunk/mysqlnd/mysqlnd_ps_codec.c 2007-08-22 14:59:54 UTC (rev 941) +++ trunk/mysqlnd/mysqlnd_ps_codec.c 2007-08-22 17:59:11 UTC (rev 942)
    @@ -23,8 +23,8 @@
    #include "mysqlnd.h" #include "mysqlnd_wireprotocol.h" #include "mysqlnd_priv.h" +#include "mysqlnd_debug.h"

-
 #define MYSQLND_SILENT    

Do you need more help?X

@@ -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;

@@ -354,7 +354,7 @@
if (!as_unicode) { #endif ZVAL_STRINGL(zv, to, length, 1); - efree(to); + mnd_efree(to); #if PHP_MAJOR_VERSION >= 6 } else { ZVAL_UTF8_STRINGL(zv, to, length, ZSTR_AUTOFREE);
@@ -402,7 +402,7 @@
if (!as_unicode) { #endif ZVAL_STRINGL(zv, to, length, 1); - efree(to); + mnd_efree(to); #if PHP_MAJOR_VERSION >= 6 } else { ZVAL_UTF8_STRINGL(zv, to, length, ZSTR_AUTOFREE);
@@ -458,7 +458,7 @@
if (!as_unicode) { #endif ZVAL_STRINGL(zv, to, length, 1); - efree(to); + mnd_efree(to); #if PHP_MAJOR_VERSION >= 6 } else { ZVAL_UTF8_STRINGL(zv, to, length, ZSTR_AUTOFREE);
Can we help you?X

@@ -667,7 +667,7 @@
unsigned int offset = *p - *buf; zend_uchar *tmp_buf; *buf_len = offset + stmt->param_count * 2 + 20; - tmp_buf = emalloc(*buf_len); + tmp_buf = mnd_emalloc(*buf_len); memcpy(tmp_buf, *buf, offset); *buf = tmp_buf;
@@ -734,7 +734,7 @@
unsigned int offset = *p - *buf; zend_uchar *tmp_buf; *buf_len = offset + data_size + 10; /* Allocate + 10 for safety */ - tmp_buf = emalloc(*buf_len); + tmp_buf = mnd_emalloc(*buf_len); memcpy(tmp_buf, *buf, offset); *buf = tmp_buf; /* Update our pos pointer */

Modified: trunk/mysqlnd/mysqlnd_result.c


  • trunk/mysqlnd/mysqlnd_result.c 2007-08-22 14:59:54 UTC (rev 941) +++ trunk/mysqlnd/mysqlnd_result.c 2007-08-22 17:59:11 UTC (rev 942)
    @@ -87,7 +87,9 @@
    unsigned int row;
 	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];

@@ -97,12 +99,15 @@
zend_bool copy_ctor_called; mysqlnd_palloc_zval_ptr_dtor(&(current_row[col]), zval_cache, result->type, ©_ctor_called TSRMLS_CC); + DBG_INF_FMT("Copy_ctor_called=%d", copy_ctor_called); MYSQLND_INC_CONN_STATISTIC(NULL, copy_ctor_called? STAT_COPY_ON_WRITE_PERFORMED: STAT_COPY_ON_WRITE_SAVED); } + DBG_INF("Freeing current_row & current_buffer"); pefree(current_row, set->persistent); pefree(current_buffer, set->persistent); } + DBG_INF("Freeing data & row_buffer"); pefree(set->data, set->persistent); pefree(set->row_buffers, set->persistent); set->data = NULL;
@@ -112,8 +117,10 @@
if (set->qcache) { mysqlnd_qcache_free_cache_reference(&set->qcache); } + DBG_INF("Freeing set"); pefree(set, set->persistent); + DBG_INF_FMT("after: real_usage=%lu usage=%lu", zend_memory_usage(TRUE TSRMLS_CC), zend_memory_usage(FALSE TSRMLS_CC));
Can't find what you're looking for?X
DBG_VOID_RETURN;

 }
 /* }}} */
@@ -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;
 	}

@@ -166,6 +174,7 @@
} if (result->zval_cache) { + DBG_INF("Freeing zval cache reference"); mysqlnd_palloc_free_thd_cache_reference(&result->zval_cache); result->zval_cache = NULL; }
@@ -488,7 +497,7 @@
UNKNOWN_SQLSTATE, mysqlnd_out_of_sync); DBG_RETURN(FAIL); } - /* Let the row packet fill our buffer and skip additional malloc + memcpy */ + /* Let the row packet fill our buffer and skip additional mnd_malloc + memcpy */ row_packet->skip_extraction = row? FALSE:TRUE; /*
@@ -608,7 +617,7 @@
result->type = MYSQLND_RES_NORMAL; result->m.fetch_row = result->m.fetch_row_normal_unbuffered; result->m.fetch_lengths = mysqlnd_fetch_lengths_unbuffered; - result->unbuf = ecalloc(1, sizeof(MYSQLND_RES_UNBUFFERED)); + result->unbuf = mnd_ecalloc(1, sizeof(MYSQLND_RES_UNBUFFERED)); /* Will be freed in the mysqlnd_internal_free_result_contents() called
@@ -621,7 +630,7 @@
result->row_packet->fields_metadata = result->meta->fields; result->row_packet->bit_fields_count = result->meta->bit_fields_count; result->row_packet->bit_fields_total_len = result->meta->bit_fields_total_len; - result->lengths = ecalloc(result->field_count, sizeof(unsigned long)); + result->lengths = mnd_ecalloc(result->field_count, sizeof(unsigned long)); /* No multithreading issues as we don't share the connection :) */

@@ -727,9 +736,9 @@
 

         free_rows = next_extend;  

  • result->data = set = pecalloc(1, sizeof(MYSQLND_RES_BUFFERED), to_cache);
  • set->data = pemalloc(STORE_RESULT_PREALLOCATED_SET * sizeof(zval **), to_cache);
  • set->row_buffers= pemalloc(STORE_RESULT_PREALLOCATED_SET * sizeof(zend_uchar *), to_cache); + result->data = set = mnd_pecalloc(1, sizeof(MYSQLND_RES_BUFFERED), to_cache); + set->data = mnd_pemalloc(STORE_RESULT_PREALLOCATED_SET * sizeof(zval **), to_cache); + set->row_buffers= mnd_pemalloc(STORE_RESULT_PREALLOCATED_SET * sizeof(zend_uchar *), to_cache); set->persistent = to_cache; set->qcache = to_cache? mysqlnd_qcache_get_cache_reference(conn->qcache):NULL; set->references = 1;
    @@ -748,9 +757,9 @@
    if (!free_rows) { mynd_ulonglong total_rows = free_rows = next_extend = next_extend * 5 / 3; /* extend with 33% */ total_rows += set->row_count;
  • set->data = perealloc(set->data, total_rows * sizeof(zval **), set->persistent); + set->data = mnd_perealloc(set->data, total_rows * sizeof(zval **), set->persistent);
  • set->row_buffers = perealloc(set->row_buffers, + set->row_buffers = mnd_perealloc(set->row_buffers, total_rows * sizeof(zend_uchar *), set->persistent); } free_rows--;
    @@ -795,10 +804,10 @@
    } /* save some memory */ if (free_rows) {
  • set->data = perealloc(set->data, + set->data = mnd_perealloc(set->data, (size_t) set->row_count * sizeof(zval **), set->persistent);
  • set->row_buffers = perealloc(set->row_buffers, + set->row_buffers = mnd_perealloc(set->row_buffers, (size_t) set->row_count * sizeof(zend_uchar *), set->persistent); }
    @@ -846,7 +855,7 @@

         conn->state = CONN_FETCHING_DATA;  

  • result->lengths = ecalloc(result->field_count, sizeof(unsigned long)); + result->lengths = mnd_ecalloc(result->field_count, sizeof(unsigned long));
 	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);
Don't know where to look next?X

Modified: trunk/mysqlnd/mysqlnd_result_meta.c


  • trunk/mysqlnd/mysqlnd_result_meta.c 2007-08-22 14:59:54 UTC (rev 941) +++ trunk/mysqlnd/mysqlnd_result_meta.c 2007-08-22 17:59:11 UTC (rev 942)
    @@ -30,15 +30,17 @@

 /* {{{ php_mysqlnd_free_field_metadata */  static
-void php_mysqlnd_free_field_metadata(MYSQLND_FIELD *meta, zend_bool persistent) +void php_mysqlnd_free_field_metadata(MYSQLND_FIELD *meta, zend_bool persistent TSRMLS_DC)  {

 	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;
 		}
 

@@ -222,7 +224,7 @@
mysqlnd_unicode_is_key_numeric(ustr, ulen + 1, &idx))) { meta->zend_hash_keys[i].key = idx; - efree(ustr); + mnd_efree(ustr); } else { meta->zend_hash_keys[i].ustr.u = ustr; meta->zend_hash_keys[i].ulen = ulen;
@@ -264,28 +266,31 @@
DBG_INF_FMT("persistent=%d", persistent); if ((fields = meta->fields)) { + DBG_INF("Freeing fields metadata"); i = meta->field_count; while (i--) { - php_mysqlnd_free_field_metadata(fields++, persistent); + php_mysqlnd_free_field_metadata(fields++, persistent TSRMLS_CC); } - pefree(meta->fields, persistent); + mnd_pefree(meta->fields, persistent); meta->fields = NULL; } if (meta->zend_hash_keys) { + DBG_INF("Freeing zend_hash_keys"); #if PHP_MAJOR_VERSION >= 6 if (UG(unicode)) { for (i = 0; i < meta->field_count; i++) { if (meta->zend_hash_keys[i].ustr.v) { - pefree(meta->zend_hash_keys[i].ustr.v, persistent); + mnd_pefree(meta->zend_hash_keys[i].ustr.v, persistent); } } } #endif - pefree(meta->zend_hash_keys, persistent); + mnd_pefree(meta->zend_hash_keys, persistent); meta->zend_hash_keys = NULL; } - pefree(meta, persistent); + DBG_INF("Freeing metadata structure"); + mnd_pefree(meta, persistent); DBG_VOID_RETURN;

 }
@@ -299,15 +304,15 @@

 {
 	unsigned int i;
 	/* +1 is to have empty marker at the end */
Call Pantek today for Open Source Technical Support at 1-877-546-8934 - 24/7/365X
- 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;
@@ -318,7 +323,7 @@
memcpy(new_fields, orig_fields, (meta->field_count) * sizeof(MYSQLND_FIELD)); for (i = 0; i < meta->field_count; i++) { /* First copy the root, then field by field adjust the pointers */ - new_fields[i].root = pemalloc(orig_fields[i].root_len, persistent); + new_fields[i].root = mnd_pemalloc(orig_fields[i].root_len, persistent); memcpy(new_fields[i].root, orig_fields[i].root, new_fields[i].root_len); if (orig_fields[i].name && orig_fields[i].name != mysqlnd_empty_string) {
@@ -345,7 +350,7 @@
} /* def is not on the root, if allocated at all */ if (orig_fields[i].def) { - new_fields[i].def = pemalloc(orig_fields[i].def_length + 1, persistent); + new_fields[i].def = mnd_pemalloc(orig_fields[i].def_length + 1, persistent); /* copy the trailing \0 too */ memcpy(new_fields[i].def, orig_fields[i].def, orig_fields[i].def_length + 1); }
@@ -416,7 +421,7 @@
DBG_ENTER("mysqlnd_result_meta_init"); /* +1 is to have empty marker at the end */
Do you need help?X
- ret = ecalloc(1, sizeof(MYSQLND_RES_METADATA)); + ret = mnd_ecalloc(1, sizeof(MYSQLND_RES_METADATA)); ret->field_count = field_count; ret->fields = ecalloc(field_count + 1, sizeof(MYSQLND_FIELD)); ret->zend_hash_keys = ecalloc(field_count, sizeof(struct mysqlnd_field_hash_key));
Confused? Frustrated?X

Modified: trunk/mysqlnd/mysqlnd_wireprotocol.c


  • trunk/mysqlnd/mysqlnd_wireprotocol.c 2007-08-22 14:59:54 UTC (rev 941) +++ trunk/mysqlnd/mysqlnd_wireprotocol.c 2007-08-22 17:59:11 UTC (rev 942)
    @@ -595,11 +595,11 @@
    { php_mysql_packet_greet *p= (php_mysql_packet_greet *) _packet; if (p->server_version) { - efree(p->server_version); + mnd_efree(p->server_version); p->server_version = NULL; } if (!alloca) { - efree(p); + mnd_efree(p); } } /* }}} */
    @@ -723,7 +723,7 @@
    void php_mysqlnd_auth_free_mem(void *_packet, zend_bool alloca) { if (!alloca) { - efree((php_mysql_packet_auth *) _packet); + mnd_efree((php_mysql_packet_auth *) _packet); } } /* }}} */
    @@ -793,11 +793,11 @@
    { php_mysql_packet_ok *p= (php_mysql_packet_ok *) _packet; if (p->message) { - efree(p->message); + mnd_efree(p->message); p->message = NULL; } if (!alloca) { - efree(p); + mnd_efree(p); } } /* }}} */
    @@ -867,7 +867,7 @@
    void php_mysqlnd_eof_free_mem(void *_packet, zend_bool alloca) { if (!alloca) { - efree(_packet); + mnd_efree(_packet); } } /* }}} */
    @@ -909,7 +909,7 @@
    #else size_t tmp_len = packet->arg_len + 1 + MYSQLND_HEADER_SIZE, ret; zend_uchar *tmp, *p; - tmp = (tmp_len > net->cmd_buffer.length)? emalloc(tmp_len):net->cmd_buffer.buffer; + tmp = (tmp_len > net->cmd_buffer.length)? mnd_emalloc(tmp_len):net->cmd_buffer.buffer; p = tmp + MYSQLND_HEADER_SIZE; /* skip the header */

                 int1store(p, packet->command);
@@ -920,7 +920,7 @@

 		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;

@@ -995,7 +995,7 @@
p+=2; /* Check for additional textual data */ if (packet->header.size > (p - buf) && (len = php_mysqlnd_net_field_length(&p))) { - 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);
 	}
Do you need more help?X

 }
 /* }}} */
@@ -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;

@@ -1150,7 +1150,7 @@
"shorter than expected. PID=%d", p - begin - packet->header.size, getpid()); } - root_ptr = meta->root = emalloc(total_len); + root_ptr = meta->root = mnd_emalloc(total_len); meta->root_len = total_len; /* Now do allocs */ if (meta->catalog && meta->catalog != mysqlnd_empty_string) {

@@ -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 */

@@ -1272,7 +1272,7 @@
We need a trailing \0 for the last string, in case of text-mode, to be able to implement read-only variables. */ - new_buf = perealloc(new_buf, *data_size + 1, persistent_alloc); + new_buf = mnd_perealloc(new_buf, *data_size + 1, persistent_alloc); /* The position could have changed, recalculate */ p = new_buf + (*data_size - header.size); }
@@ -1628,7 +1628,7 @@
but mostly like old-API unbuffered and thus will populate this array with value. */ - packet->fields = (zval **) pemalloc(packet->field_count * sizeof(zval *), + packet->fields = (zval **) mnd_pemalloc(packet->field_count * sizeof(zval *), packet->persistent_alloc); }

@@ -1655,7 +1655,7 @@

 {

 	php_mysql_packet_row *p= (php_mysql_packet_row *) _packet;
Can we help you?X
if (p->row_buffer) { - pefree(p->row_buffer, p->persistent_alloc); + mnd_pefree(p->row_buffer, p->persistent_alloc); p->row_buffer = NULL; } /*
@@ -1666,7 +1666,7 @@
not free the array. As it is passed to us, we should not clean it ourselves. */ if (!alloca) { - efree(p); + mnd_efree(p); }

 }
 /* }}} */
@@ -1684,7 +1684,7 @@
 

         PACKET_READ_HEADER_AND_BODY(packet, conn, buf, sizeof(buf), "statistics");  

  • packet->message = pemalloc(packet->header.size + 1, conn->persistent); + packet->message = mnd_pemalloc(packet->header.size + 1, conn->persistent); memcpy(packet->message, buf, packet->header.size); packet->message[packet->header.size] = '\0'; packet->message_len = packet->header.size;
    @@ -1700,11 +1700,11 @@
    { php_mysql_packet_stats *p= (php_mysql_packet_stats *) _packet; if (p->message) {
  • efree(p->message); + mnd_efree(p->message); p->message = NULL; } if (!alloca) {
  • efree(p); + mnd_efree(p); } } /* }}} */
    @@ -1788,7 +1788,7 @@
    { php_mysql_packet_prepare_response *p= (php_mysql_packet_prepare_response *) _packet; if (!alloca) {
  • efree(p); + mnd_efree(p); } } /* }}} */
    @@ -1847,7 +1847,7 @@
    void php_mysqlnd_chg_user_free_mem(void *_packet, zend_bool alloca) { if (!alloca) {
  • efree(_packet); + mnd_efree(_packet); } } /* }}} */
-- 
MySQL Code Commits Mailing List
For list archives: 
http://lists.mysql.com/commits
To unsubscribe:    
http://lists.mysql.com/commits?unsub=lists@pantek.com
Received 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


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library