fix gc issues
[m6w6/ext-http] / http_api.c
index 61de3e81f1448d352c367d8596a145b1f597215e..4ab7d7edbd1862d4eb6b2ab41ef7eb0666907717 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "php_output.h"
 #include "ext/standard/url.h"
+#include "ext/standard/php_lcg.h"
 
 #include "php_http_api.h"
 #include "php_http_send_api.h"
@@ -94,6 +95,13 @@ char *_http_pretty_key(char *key, size_t key_len, zend_bool uctitle, zend_bool x
 }
 /* }}} */
 
+/* {{{ http_boundary(char *, size_t) */
+size_t _http_boundary(char *buf, size_t buf_len TSRMLS_DC)
+{
+       return snprintf(buf, buf_len, "%lu%0.9f", (ulong) HTTP_G->request.time, (float) php_combined_lcg(TSRMLS_C));
+}
+/* }}} */
+
 /* {{{ void http_error(long, long, char*) */
 void _http_error_ex(long type TSRMLS_DC, long code, const char *format, ...)
 {
@@ -184,7 +192,7 @@ STATUS _http_object_new(zend_object_value *ov, const char *cname_str, uint cname
        zend_class_entry *ce = parent_ce;
        
        if (cname_str && cname_len) {
-               if (!(ce = zend_fetch_class((char *) cname_str, cname_len, ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC))) {
+               if (!(ce = zend_fetch_class(HTTP_ZAPI_CONST_CAST(char *) cname_str, cname_len, ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC))) {
                        return FAILURE;
                }
                if (!instanceof_function(ce, parent_ce TSRMLS_CC)) {
@@ -314,7 +322,7 @@ PHP_HTTP_API zval *_http_get_server_var_ex(const char *key, size_t key_len, zend
        if ((SUCCESS != zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void *) &hsv)) || (Z_TYPE_PP(hsv) != IS_ARRAY)) {
                return NULL;
        }
-       if ((SUCCESS != zend_hash_find(Z_ARRVAL_PP(hsv), (char *) key, key_len + 1, (void *) &var))) {
+       if ((SUCCESS != zend_hash_find(Z_ARRVAL_PP(hsv), HTTP_ZAPI_CONST_CAST(char *) key, key_len + 1, (void *) &var))) {
                return NULL;
        }
        if (check && !((Z_TYPE_PP(var) == IS_STRING) && Z_STRVAL_PP(var) && Z_STRLEN_PP(var))) {