summaryrefslogtreecommitdiff
path: root/ext/standard/php_var.h
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard/php_var.h')
-rw-r--r--ext/standard/php_var.h69
1 files changed, 9 insertions, 60 deletions
diff --git a/ext/standard/php_var.h b/ext/standard/php_var.h
index 4afefbe95a..80208d29ee 100644
--- a/ext/standard/php_var.h
+++ b/ext/standard/php_var.h
@@ -38,18 +38,6 @@ PHPAPI void php_var_export_ex(zval *struc, int level, smart_str *buf);
PHPAPI void php_debug_zval_dump(zval *struc, int level);
-struct php_serialize_data {
- HashTable ht;
- uint32_t n;
-};
-
-struct php_unserialize_data {
- void *first;
- void *last;
- void *first_dtor;
- void *last_dtor;
-};
-
typedef struct php_serialize_data *php_serialize_data_t;
typedef struct php_unserialize_data *php_unserialize_data_t;
@@ -59,61 +47,22 @@ PHPAPI int php_var_unserialize_ref(zval *rval, const unsigned char **p, const un
PHPAPI int php_var_unserialize_intern(zval *rval, const unsigned char **p, const unsigned char *max, php_unserialize_data_t *var_hash);
PHPAPI int php_var_unserialize_ex(zval *rval, const unsigned char **p, const unsigned char *max, php_unserialize_data_t *var_hash, HashTable *classes);
+PHPAPI php_serialize_data_t php_var_serialize_init(void);
+PHPAPI void php_var_serialize_destroy(php_serialize_data_t d);
+PHPAPI php_unserialize_data_t php_var_unserialize_init(void);
+PHPAPI void php_var_unserialize_destroy(php_unserialize_data_t d);
+
#define PHP_VAR_SERIALIZE_INIT(d) \
-do { \
- /* fprintf(stderr, "SERIALIZE_INIT == lock: %u, level: %u\n", BG(serialize_lock), BG(serialize).level); */ \
- if (BG(serialize_lock) || !BG(serialize).level) { \
- (d) = (php_serialize_data_t) emalloc(sizeof(struct php_serialize_data)); \
- zend_hash_init(&(d)->ht, 16, NULL, ZVAL_PTR_DTOR, 0); \
- (d)->n = 0; \
- if (!BG(serialize_lock)) { \
- BG(serialize).data = d; \
- BG(serialize).level = 1; \
- } \
- } else { \
- (d) = BG(serialize).data; \
- ++BG(serialize).level; \
- } \
-} while(0)
+ (d) = php_var_serialize_init()
#define PHP_VAR_SERIALIZE_DESTROY(d) \
-do { \
- /* fprintf(stderr, "SERIALIZE_DESTROY == lock: %u, level: %u\n", BG(serialize_lock), BG(serialize).level); */ \
- if (BG(serialize_lock) || BG(serialize).level == 1) { \
- zend_hash_destroy(&(d)->ht); \
- efree((d)); \
- } \
- if (!BG(serialize_lock) && !--BG(serialize).level) { \
- BG(serialize).data = NULL; \
- } \
-} while (0)
+ php_var_serialize_destroy(d)
#define PHP_VAR_UNSERIALIZE_INIT(d) \
-do { \
- /* fprintf(stderr, "UNSERIALIZE_INIT == lock: %u, level: %u\n", BG(serialize_lock), BG(unserialize).level); */ \
- if (BG(serialize_lock) || !BG(unserialize).level) { \
- (d) = (php_unserialize_data_t)ecalloc(1, sizeof(struct php_unserialize_data)); \
- if (!BG(serialize_lock)) { \
- BG(unserialize).data = (d); \
- BG(unserialize).level = 1; \
- } \
- } else { \
- (d) = BG(unserialize).data; \
- ++BG(unserialize).level; \
- } \
-} while (0)
+ (d) = php_var_unserialize_init()
#define PHP_VAR_UNSERIALIZE_DESTROY(d) \
-do { \
- /* fprintf(stderr, "UNSERIALIZE_DESTROY == lock: %u, level: %u\n", BG(serialize_lock), BG(unserialize).level); */ \
- if (BG(serialize_lock) || BG(unserialize).level == 1) { \
- var_destroy(&(d)); \
- efree((d)); \
- } \
- if (!BG(serialize_lock) && !--BG(unserialize).level) { \
- BG(unserialize).data = NULL; \
- } \
-} while (0)
+ php_var_unserialize_destroy(d)
PHPAPI void var_replace(php_unserialize_data_t *var_hash, zval *ozval, zval *nzval);
PHPAPI void var_push_dtor(php_unserialize_data_t *var_hash, zval *val);