diff options
| -rw-r--r-- | ext/wddx/wddx.c | 72 |
1 files changed, 40 insertions, 32 deletions
diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c index 3f983567f2..0324f541ec 100644 --- a/ext/wddx/wddx.c +++ b/ext/wddx/wddx.c @@ -238,12 +238,12 @@ static int wddx_stack_destroy(wddx_stack *stack) if (stack->elements) { for (i = 0; i < stack->top; i++) { - if (((st_entry *)stack->elements[i])->data) - { + if (((st_entry *)stack->elements[i])->data) { zval_ptr_dtor(&((st_entry *)stack->elements[i])->data); } - if (((st_entry *)stack->elements[i])->varname) + if (((st_entry *)stack->elements[i])->varname) { efree(((st_entry *)stack->elements[i])->varname); + } efree(stack->elements[i]); } efree(stack->elements); @@ -286,8 +286,9 @@ PS_SERIALIZER_ENCODE_FUNC(wddx) *newstr = php_wddx_gather(packet); php_wddx_destructor(packet); - if (newlen) + if (newlen) { *newlen = strlen(*newstr); + } return SUCCESS; } @@ -306,8 +307,9 @@ PS_SERIALIZER_DECODE_FUNC(wddx) int hash_type; int ret; - if (vallen == 0) + if (vallen == 0) { return SUCCESS; + } MAKE_STD_ZVAL(retval); @@ -379,8 +381,9 @@ void php_wddx_packet_start(wddx_packet *packet, char *comment, int comment_len) php_wddx_add_chunk_ex(packet, comment, comment_len); php_wddx_add_chunk_static(packet, WDDX_COMMENT_E); php_wddx_add_chunk_static(packet, WDDX_HEADER_E); - } else + } else { php_wddx_add_chunk_static(packet, WDDX_HEADER); + } php_wddx_add_chunk_static(packet, WDDX_DATA_S); } /* }}} */ @@ -525,8 +528,9 @@ static void php_wddx_serialize_object(wddx_packet *packet, zval *obj) for (zend_hash_internal_pointer_reset(HASH_OF(obj)); zend_hash_get_current_data(HASH_OF(obj), (void**)&ent) == SUCCESS; zend_hash_move_forward(HASH_OF(obj))) { - if (*ent == obj) + if (*ent == obj) { continue; + } if (zend_hash_get_current_key_ex(HASH_OF(obj), &key, &key_len, &idx, 0, NULL) == HASH_KEY_IS_STRING) { char *class_name, *prop_name; @@ -596,8 +600,9 @@ static void php_wddx_serialize_array(wddx_packet *packet, zval *arr) for (zend_hash_internal_pointer_reset(target_hash); zend_hash_get_current_data(target_hash, (void**)&ent) == SUCCESS; zend_hash_move_forward(target_hash)) { - if (*ent == arr) + if (*ent == arr) { continue; + } if (is_struct) { ent_type = zend_hash_get_current_key_ex(target_hash, &key, &key_len, &idx, 0, NULL); @@ -608,8 +613,9 @@ static void php_wddx_serialize_array(wddx_packet *packet, zval *arr) key_len = slprintf(tmp_buf, sizeof(tmp_buf), "%ld", idx); php_wddx_serialize_var(packet, *ent, tmp_buf, key_len TSRMLS_CC); } - } else + } else { php_wddx_serialize_var(packet, *ent, NULL, 0 TSRMLS_CC); + } } if (is_struct) { @@ -693,8 +699,7 @@ static void php_wddx_add_var(wddx_packet *packet, zval *name_var) HashTable *target_hash; TSRMLS_FETCH(); - if (Z_TYPE_P(name_var) == IS_STRING) - { + if (Z_TYPE_P(name_var) == IS_STRING) { if (!EG(active_symbol_table)) { zend_rebuild_symbol_table(TSRMLS_C); } @@ -702,9 +707,7 @@ static void php_wddx_add_var(wddx_packet *packet, zval *name_var) Z_STRLEN_P(name_var)+1, (void**)&val) != FAILURE) { php_wddx_serialize_var(packet, *val, Z_STRVAL_P(name_var), Z_STRLEN_P(name_var) TSRMLS_CC); } - } - else if (Z_TYPE_P(name_var) == IS_ARRAY || Z_TYPE_P(name_var) == IS_OBJECT) - { + } else if (Z_TYPE_P(name_var) == IS_ARRAY || Z_TYPE_P(name_var) == IS_OBJECT) { target_hash = HASH_OF(name_var); zend_hash_internal_pointer_reset(target_hash); @@ -919,8 +922,9 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name) TSRMLS_FETCH(); /* OBJECTS_FIXME */ - if (stack->top == 0) + if (stack->top == 0) { return; + } if (!strcmp(name, EL_STRING) || !strcmp(name, EL_NUMBER) || !strcmp(name, EL_BOOLEAN) || !strcmp(name, EL_NULL) || @@ -950,8 +954,9 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name) zval_dtor(fname); FREE_ZVAL(fname); - if (retval) + if (retval) { zval_ptr_dtor(&retval); + } } if (stack->top > 1) { @@ -1014,14 +1019,13 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name) } efree(ent1->varname); } else { - zend_hash_next_index_insert(target_hash, - &ent1->data, - sizeof(zval *), NULL); + zend_hash_next_index_insert(target_hash, &ent1->data, sizeof(zval *), NULL); } } efree(ent1); - } else + } else { stack->done = 1; + } } else if (!strcmp(name, EL_VAR) && stack->varname) { efree(stack->varname); } else if (!strcmp(name, EL_FIELD)) { @@ -1083,11 +1087,11 @@ static void php_wddx_process_data(void *user_data, const XML_Char *s, int len) break; case ST_BOOLEAN: - if (!strcmp(s, "true")) + if (!strcmp(s, "true")) { Z_LVAL_P(ent->data) = 1; - else if (!strcmp(s, "false")) + } else if (!strcmp(s, "false")) { Z_LVAL_P(ent->data) = 0; - else { + } else { stack->top--; zval_ptr_dtor(&ent->data); if (ent->varname) @@ -1146,8 +1150,9 @@ int php_wddx_deserialize_ex(char *value, int vallen, zval *return_value) *return_value = *(ent->data); zval_copy_ctor(return_value); retval = SUCCESS; - } else + } else { retval = FAILURE; + } wddx_stack_destroy(&stack); @@ -1164,9 +1169,9 @@ PHP_FUNCTION(wddx_serialize_value) int comment_len = 0; wddx_packet *packet; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|s", - &var, &comment, &comment_len) == FAILURE) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|s", &var, &comment, &comment_len) == FAILURE) { return; + } packet = php_wddx_constructor(); @@ -1247,8 +1252,9 @@ PHP_FUNCTION(wddx_packet_start) comment = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &comment, &comment_len) == FAILURE) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &comment, &comment_len) == FAILURE) { return; + } packet = php_wddx_constructor(); @@ -1323,14 +1329,14 @@ PHP_FUNCTION(wddx_deserialize) int payload_len; php_stream *stream = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &packet) == FAILURE) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &packet) == FAILURE) { return; + } if (Z_TYPE_P(packet) == IS_STRING) { payload = Z_STRVAL_P(packet); payload_len = Z_STRLEN_P(packet); - } - else if (Z_TYPE_P(packet) == IS_RESOURCE) { + } else if (Z_TYPE_P(packet) == IS_RESOURCE) { php_stream_from_zval(stream, &packet); if (stream) { payload_len = php_stream_copy_to_mem(stream, &payload, PHP_STREAM_COPY_ALL, 0); @@ -1340,13 +1346,15 @@ PHP_FUNCTION(wddx_deserialize) return; } - if (payload_len == 0) + if (payload_len == 0) { return; + } php_wddx_deserialize_ex(payload, payload_len, return_value); - if (stream) + if (stream) { pefree(payload, 0); + } } /* }}} */ |
