]> granicus.if.org Git - php/commitdiff
Fix the Windows build (void* arithmetic) as well as --disable-zlib
authorAndrey Hristov <andrey@php.net>
Tue, 6 Apr 2010 18:14:23 +0000 (18:14 +0000)
committerAndrey Hristov <andrey@php.net>
Tue, 6 Apr 2010 18:14:23 +0000 (18:14 +0000)
build.

ext/mysqlnd/mysqlnd_debug.c
ext/mysqlnd/mysqlnd_net.c

index 0254528889892156fe6dfb64471d61ea794eba00..79771d758610abbba7784cf3d03de03630f2347a 100644 (file)
@@ -757,7 +757,7 @@ void * _mysqlnd_erealloc(void *ptr, size_t new_size MYSQLND_MEM_D)
 {
        void *ret;
        zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
-       size_t old_size = collect_memory_statistics && ptr? *(size_t *) (ptr - sizeof(size_t)) : 0;
+       size_t old_size = collect_memory_statistics && ptr? *(size_t *) (((char*)ptr) - sizeof(size_t)) : 0;
        DBG_ENTER(mysqlnd_erealloc_name);
        DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
        DBG_INF_FMT("ptr=%p old_size=%lu, new_size=%lu", ptr, old_size, new_size); 
@@ -779,7 +779,7 @@ void * _mysqlnd_perealloc(void *ptr, size_t new_size, zend_bool persistent MYSQL
 {
        void *ret;
        zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
-       size_t old_size = collect_memory_statistics && ptr? *(size_t *) (ptr - sizeof(size_t)) : 0;
+       size_t old_size = collect_memory_statistics && ptr? *(size_t *) (((char*)ptr) - sizeof(size_t)) : 0;
        DBG_ENTER(mysqlnd_perealloc_name);
        DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
        DBG_INF_FMT("ptr=%p old_size=%lu new_size=%lu persist=%d", ptr, old_size, new_size, persistent); 
@@ -810,8 +810,8 @@ void _mysqlnd_efree(void *ptr MYSQLND_MEM_D)
 
        if (ptr) {
                if (collect_memory_statistics) {
-                       free_amount = *(size_t *)(ptr - sizeof(size_t));
-                       DBG_INF_FMT("ptr=%p size=%u", ptr - sizeof(size_t), (unsigned int) free_amount);
+                       free_amount = *(size_t *)(((char*)ptr) - sizeof(size_t));
+                       DBG_INF_FMT("ptr=%p size=%u", ((char*)ptr) - sizeof(size_t), (unsigned int) free_amount);
                }
                efree(REAL_PTR(ptr));
        }
@@ -835,8 +835,8 @@ void _mysqlnd_pefree(void *ptr, zend_bool persistent MYSQLND_MEM_D)
 
        if (ptr) {
                if (collect_memory_statistics) {
-                       free_amount = *(size_t *)(ptr - sizeof(size_t));
-                       DBG_INF_FMT("ptr=%p size=%u", ptr - sizeof(size_t), (unsigned int) free_amount);
+                       free_amount = *(size_t *)(((char*)ptr) - sizeof(size_t));
+                       DBG_INF_FMT("ptr=%p size=%u", ((char*)ptr) - sizeof(size_t), (unsigned int) free_amount);
                }
                pefree(REAL_PTR(ptr), persistent);
        }
@@ -923,8 +923,8 @@ void _mysqlnd_free(void *ptr MYSQLND_MEM_D)
 
        if (ptr) {
                if (collect_memory_statistics) {
-                       free_amount = *(size_t *)(ptr - sizeof(size_t));
-                       DBG_INF_FMT("ptr=%p size=%u", ptr - sizeof(size_t), (unsigned int) free_amount);
+                       free_amount = *(size_t *)(((char*)ptr) - sizeof(size_t));
+                       DBG_INF_FMT("ptr=%p size=%u", ((char*)ptr) - sizeof(size_t), (unsigned int) free_amount);
                }
                free(REAL_PTR(ptr));
        }
@@ -976,7 +976,7 @@ char * _mysqlnd_pestrdup(const char * const ptr, zend_bool persistent MYSQLND_ME
 {
        char * ret;
        smart_str tmp_str = {0, 0, 0};
-       char * p = ptr;
+       const char * p = ptr;
        zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
        DBG_ENTER(mysqlnd_pestrdup_name);
        DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
index 1587acf482bdcb825d1629d95400eaf47ec0d00b..d88e20418cfc79bb66fabc51ed2efc629f6290df 100644 (file)
@@ -448,6 +448,7 @@ static enum_func_status
 MYSQLND_METHOD(mysqlnd_net, decode)(zend_uchar * uncompressed_data, size_t uncompressed_data_len,
                                                                        const zend_uchar * const compressed_data, size_t compressed_data_len TSRMLS_DC)
 {
+#ifdef MYSQLND_COMPRESSION_ENABLED
        int error;
        uLongf tmp_complen = uncompressed_data_len;
        DBG_ENTER("mysqlnd_net::decode");
@@ -458,6 +459,10 @@ MYSQLND_METHOD(mysqlnd_net, decode)(zend_uchar * uncompressed_data, size_t uncom
                DBG_INF_FMT("decompression NOT successful. error=%d Z_OK=%d Z_BUF_ERROR=%d Z_MEM_ERROR=%d", error, Z_OK, Z_BUF_ERROR, Z_MEM_ERROR);
        }
        DBG_RETURN(error == Z_OK? PASS:FAIL);
+#else
+       DBG_ENTER("mysqlnd_net::decode");
+       DBG_RETURN(FAIL);
+#endif
 }
 /* }}} */
 
@@ -467,6 +472,7 @@ static enum_func_status
 MYSQLND_METHOD(mysqlnd_net, encode)(zend_uchar * compress_buffer, size_t compress_buffer_len,
                                                                        const zend_uchar * const uncompressed_data, size_t uncompressed_data_len TSRMLS_DC)
 {
+#ifdef MYSQLND_COMPRESSION_ENABLED
        int error;
        uLongf tmp_complen = compress_buffer_len;
        DBG_ENTER("mysqlnd_net::encode");
@@ -478,6 +484,10 @@ MYSQLND_METHOD(mysqlnd_net, encode)(zend_uchar * compress_buffer, size_t compres
                DBG_INF_FMT("compression successful. compressed size=%d", tmp_complen);
        }
        DBG_RETURN(error == Z_OK? PASS:FAIL);
+#else
+       DBG_ENTER("mysqlnd_net::encode");
+       DBG_RETURN(FAIL);
+#endif
 }
 /* }}} */