{
UNREGISTER_INI_ENTRIES();
#ifdef HTTP_HAVE_CURL
- //phpstr_free(&HTTP_G(curlbuf));
+ phpstr_dtor(&HTTP_G(curlbuf));
curl_global_cleanup();
#endif
return SUCCESS;
}
#ifdef HTTP_HAVE_CURL
- //phpstr_free(&HTTP_G(curlbuf));
+ phpstr_dtor(&HTTP_G(curlbuf));
#endif
return SUCCESS;
/* }}} */
/* {{{ STATUS http_chunked_decode(char *, size_t, char **, size_t *) */
-PHP_HTTP_API STATUS _http_chunked_decode(const char *encoded, size_t encoded_len,
+PHP_HTTP_API STATUS _http_chunked_decode(const char *encoded, size_t encoded_len,
char **decoded, size_t *decoded_len TSRMLS_DC)
{
const char *e_ptr;
if (SUCCESS != http_urlencode_hash_implementation(hash, qstr, arg_sep)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't encode query data");
- phpstr_dtor(qstr);
+ phpstr_free(qstr);
return FAILURE;
}
phpstr_data(qstr, encoded_data, encoded_len);
- phpstr_dtor(qstr);
+ phpstr_free(qstr);
return SUCCESS;
}
ulong idx;
zval **zdata = NULL, *copyzval;
- if (!ht) {
+ if (!ht || !formstr) {
return FAILURE;
}
*p = '\0';
}
ht->nApplyCount++;
- http_urlencode_hash_implementation_ex(HASH_OF(*zdata), formstr, arg_sep,
+ http_urlencode_hash_implementation_ex(HASH_OF(*zdata), formstr, arg_sep,
NULL, 0, newprefix, newprefix_len, "]", 1, (Z_TYPE_PP(zdata) == IS_OBJECT ? *zdata : NULL));
ht->nApplyCount--;
efree(newprefix);
}
#define http_curl_cleanup(ch, clean_curl) \
- phpstr_free(&HTTP_G(curlbuf)); \
+ phpstr_dtor(&HTTP_G(curlbuf)); \
zend_llist_clean(&HTTP_G(to_free)); \
if (clean_curl) { \
curl_easy_cleanup(ch); \
phpstr_fix(qstr);
curl_easy_setopt(ch, CURLOPT_COOKIE, http_curl_copystr(qstr->data));
}
- phpstr_dtor(qstr);
+ phpstr_free(qstr);
}
/* cookiestore */
status = http_post_data_ex(ch, URL, encoded, encoded_len, options, info, data, data_len);
efree(encoded);
-
+
return status;
}
/* }}} */
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
-
}
if (SUCCESS != http_urlencode_hash_implementation_ex(HASH_OF(formdata), formstr, arg_sep, prefix, prefix_len, NULL, 0, NULL, 0, (Z_TYPE_P(formdata) == IS_OBJECT ? formdata : NULL) TSRMLS_CC)) {
- phpstr_dtor(formstr);
+ phpstr_free(formstr);
RETURN_FALSE;
}
if (!formstr->used) {
+ phpstr_free(formstr);
RETURN_NULL();
}
zval *dispo_file = GET_PROP(obj, dispoFile);
if (Z_STRLEN_P(dispo_file)) {
zval *dispo_inline = GET_PROP(obj, dispoInline);
- http_send_content_disposition(Z_STRVAL_P(dispo_file), Z_STRLEN_P(dispo_file), Z_LVAL_P(dispo_inline));
+ http_send_content_disposition(Z_STRVAL_P(dispo_file), Z_STRLEN_P(dispo_file), (zend_bool) Z_LVAL_P(dispo_inline));
}
}
#include "phpstr.h"
#ifndef PHPSTR_DEFAULT_SIZE
-#define PHPSTR_DEFAULT_SIZE 4096
+#define PHPSTR_DEFAULT_SIZE 256
#endif
PHPSTR_API phpstr *phpstr_init_ex(phpstr *buf, size_t chunk_size, zend_bool pre_alloc)
buf = ecalloc(1, sizeof(phpstr));
}
- buf->used = 0;
buf->size = chunk_size > 0 ? chunk_size : PHPSTR_DEFAULT_SIZE;
- buf->free = pre_alloc ? buf->size : 0;
buf->data = pre_alloc ? emalloc(buf->size) : NULL;
+ buf->free = pre_alloc ? buf->size : 0;
+ buf->used = 0;
return buf;
}
PHPSTR_API phpstr *phpstr_from_string_ex(phpstr *buf, char *string, size_t length)
{
- buf = phpstr_init(buf);
+ buf = phpstr_init(buf);
phpstr_append(buf, string, length);
return buf;
}
}
}
-PHPSTR_API void phpstr_free(phpstr *buf)
+PHPSTR_API void phpstr_dtor(phpstr *buf)
{
if (buf->data) {
efree(buf->data);
buf->free = 0;
}
-PHPSTR_API void phpstr_dtor(phpstr *buf)
+PHPSTR_API void phpstr_free(phpstr *buf)
{
if (buf) {
- phpstr_free(buf);
+ phpstr_dtor(buf);
efree(buf);
}
}
# define PHPSTR_API
#endif
-#define FREE_PHPSTR_PTR(STR) phpstr_dtor(STR)
-#define FREE_PHPSTR_VAL(STR) phpstr_free(STR)
+#define FREE_PHPSTR_PTR(STR) efree(STR)
+#define FREE_PHPSTR_VAL(STR) phpstr_dtor(STR)
+#define FREE_PHPSTR_ALL(STR) phpstr_free(STR)
#define FREE_PHPSTR(free, STR) \
switch (free) \
{ \
- case PHPSTR_FREE_VAL: phpstr_free(STR); break; \
- case PHPSTR_FREE_PTR: phpstr_dtor(STR); break; \
+ case PHPSTR_FREE_PTR: efree(STR); break; \
+ case PHPSTR_FREE_VAL: phpstr_dtor(STR); break; \
+ case PHPSTR_FREE_ALL: phpstr_free(STR); break; \
case PHPSTR_FREE_NOT: break; \
default: break; \
}
-#define RETURN_PHPSTR_PTR(STR) RETURN_PHPSTR((STR), PHPSTR_FREE_PTR)
-#define RETURN_PHPSTR_VAL(STR) RETURN_PHPSTR((STR), PHPSTR_FREE_VAL)
-#define RETURN_PHPSTR(STR, free) \
- RETVAL_PHPSTR((STR), (free)); \
+#define RETURN_PHPSTR_PTR(STR) RETURN_PHPSTR((STR), PHPSTR_FREE_PTR, 0)
+#define RETURN_PHPSTR_VAL(STR) RETURN_PHPSTR(&(STR), PHPSTR_FREE_NOT, 0)
+/* RETURN_PHPSTR(buf, PHPSTR_FREE_PTR, 0) */
+#define RETURN_PHPSTR(STR, free, dup) \
+ RETVAL_PHPSTR((STR), (free), (dup)); \
return;
-#define RETVAL_PHPSTR_PTR(STR) RETVAL_PHPSTR((STR), PHPSTR_FREE_PTR)
-#define RETVAL_PHPSTR_VAL(STR) RETVAL_PHPSTR((STR), PHPSTR_FREE_VAL)
-#define RETVAL_PHPSTR(STR, free) \
+#define RETVAL_PHPSTR(STR, free, dup) \
phpstr_fix(STR); \
- RETVAL_STRINGL((STR)->data, (STR)->used, 1); \
+ RETVAL_STRINGL((STR)->data, (STR)->used, (dup)); \
FREE_PHPSTR((free), (STR));
struct _phpstr {
enum _phpstr_free {
PHPSTR_FREE_NOT = 0,
- PHPSTR_FREE_VAL = 1, /* phpstr_free() */
- PHPSTR_FREE_PTR = 2 /* phpstr_dtor() */
+ PHPSTR_FREE_PTR, /* efree() */
+ PHPSTR_FREE_VAL, /* phpstr_dtor() */
+ PHPSTR_FREE_ALL /* phpstr_free() */
};
typedef enum _phpstr_free phpstr_free_t;
+#define PHPSTR_ALL_FREE(STR) PHPSTR_FREE_ALL,(STR)
#define PHPSTR_PTR_FREE(STR) PHPSTR_FREE_PTR,(STR)
#define PHPSTR_VAL_FREE(STR) PHPSTR_FREE_VAL,(STR)
#define PHPSTR_NOT_FREE(STR) PHPSTR_FREE_NOT,(STR)
phpstr *final = phpstr_merge(3,
PHPSTR_NOT_FREE(&keep),
- PHPSTR_PTR_FREE(middle_ptr),
+ PHPSTR_ALL_FREE(middle_ptr),
PHPSTR_VAL_FREE(&local);
*/
PHPSTR_API phpstr *phpstr_merge(unsigned argc, ...);
/* sets a trailing NUL byte */
PHPSTR_API void phpstr_fix(phpstr *buf);
-/* free a phpstr objects data (resets used and free) */
-PHPSTR_API void phpstr_free(phpstr *buf);
-
-/* free a phpstr object (calls phpstr_free, too) */
-#define phpstr_del(b) phpstr_dtor(b)
+/* free a phpstr objects contents */
PHPSTR_API void phpstr_dtor(phpstr *buf);
+/* free a phpstr object completely */
+PHPSTR_API void phpstr_free(phpstr *buf);
+
#endif