diff options
author | Dmitry Stogov <dmitry@zend.com> | 2015-06-30 04:05:24 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2015-06-30 04:05:24 +0300 |
commit | 4a2e40bb861bc3cf5fb6863e57486ed60316e97c (patch) | |
tree | 6579660b282fdd1bc50095e48d702913a0b6aa97 /ext/zlib/zlib.c | |
parent | 8cce5b2641fb91c3073018b59f6f044b843041a8 (diff) | |
download | php-git-4a2e40bb861bc3cf5fb6863e57486ed60316e97c.tar.gz |
Use ZSTR_ API to access zend_string elements (this is just renaming without semantick changes).
Diffstat (limited to 'ext/zlib/zlib.c')
-rw-r--r-- | ext/zlib/zlib.c | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index b4b95e85a5..2d141597ed 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -351,9 +351,9 @@ static zend_string *php_zlib_encode(const char *in_buf, size_t in_len, int encod out = zend_string_alloc(PHP_ZLIB_BUFFER_SIZE_GUESS(in_len), 0); Z.next_in = (Bytef *) in_buf; - Z.next_out = (Bytef *) out->val; + Z.next_out = (Bytef *) ZSTR_VAL(out); Z.avail_in = in_len; - Z.avail_out = out->len; + Z.avail_out = ZSTR_LEN(out); status = deflate(&Z, Z_FINISH); deflateEnd(&Z); @@ -361,7 +361,7 @@ static zend_string *php_zlib_encode(const char *in_buf, size_t in_len, int encod if (Z_STREAM_END == status) { /* size buffer down to actual length */ out = zend_string_truncate(out, Z.total_out, 0); - out->val[out->len] = '\0'; + ZSTR_VAL(out)[ZSTR_LEN(out)] = '\0'; return out; } else { zend_string_free(out); @@ -687,7 +687,7 @@ static PHP_FUNCTION(name) \ php_error_docref(NULL, E_WARNING, "encoding mode must be either ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE"); \ RETURN_FALSE; \ } \ - if ((out = php_zlib_encode(in->val, in->len, encoding, level)) == NULL) { \ + if ((out = php_zlib_encode(ZSTR_VAL(in), ZSTR_LEN(in), encoding, level)) == NULL) { \ RETURN_FALSE; \ } \ RETURN_STR(out); \ @@ -766,8 +766,8 @@ static zend_bool zlib_create_dictionary_string(HashTable *options, char **dict, int i; zend_bool last_null = 1; - for (i = 0; i < str->len; i++) { - if (str->val[i]) { + for (i = 0; i < ZSTR_LEN(str); i++) { + if (ZSTR_VAL(str)[i]) { last_null = 0; } else { if (last_null) { @@ -781,9 +781,9 @@ static zend_bool zlib_create_dictionary_string(HashTable *options, char **dict, php_error_docref(NULL, E_WARNING, "dictionary string must be NULL-byte terminated (each dictionary entry has to be NULL-terminated)"); } - *dict = emalloc(str->len); - memcpy(*dict, str->val, str->len); - *dictlen = str->len; + *dict = emalloc(ZSTR_LEN(str)); + memcpy(*dict, ZSTR_VAL(str), ZSTR_LEN(str)); + *dictlen = ZSTR_LEN(str); } break; case IS_ARRAY: { @@ -799,7 +799,7 @@ static zend_bool zlib_create_dictionary_string(HashTable *options, char **dict, int i; *++ptr = zval_get_string(cur); - if (!*ptr || (*ptr)->len == 0) { + if (!*ptr || ZSTR_LEN(*ptr) == 0) { if (*ptr) { efree(*ptr); } @@ -810,8 +810,8 @@ static zend_bool zlib_create_dictionary_string(HashTable *options, char **dict, php_error_docref(NULL, E_WARNING, "dictionary entries must be non-empty strings"); return 0; } - for (i = 0; i < (*ptr)->len; i++) { - if ((*ptr)->val[i] == 0) { + for (i = 0; i < ZSTR_LEN(*ptr); i++) { + if (ZSTR_VAL(*ptr)[i] == 0) { do { efree(ptr); } while (--ptr >= strings); @@ -821,15 +821,15 @@ static zend_bool zlib_create_dictionary_string(HashTable *options, char **dict, } } - *dictlen += (*ptr)->len + 1; + *dictlen += ZSTR_LEN(*ptr) + 1; } ZEND_HASH_FOREACH_END(); dictptr = *dict = emalloc(*dictlen); ptr = strings; end = strings + zend_hash_num_elements(dictionary); do { - memcpy(dictptr, (*ptr)->val, (*ptr)->len); - dictptr += (*ptr)->len; + memcpy(dictptr, ZSTR_VAL(*ptr), ZSTR_LEN(*ptr)); + dictptr += ZSTR_LEN(*ptr); *dictptr++ = 0; zend_string_release(*ptr); } while (++ptr != end); @@ -947,21 +947,21 @@ PHP_FUNCTION(inflate_add) out = zend_string_alloc((in_len > CHUNK_SIZE) ? in_len : CHUNK_SIZE, 0); ctx->next_in = (Bytef *) in_buf; - ctx->next_out = (Bytef *) out->val; + ctx->next_out = (Bytef *) ZSTR_VAL(out); ctx->avail_in = in_len; - ctx->avail_out = out->len; + ctx->avail_out = ZSTR_LEN(out); do { status = inflate(ctx, flush_type); - buffer_used = out->len - ctx->avail_out; + buffer_used = ZSTR_LEN(out) - ctx->avail_out; switch (status) { case Z_OK: if (ctx->avail_out == 0) { /* more output buffer space needed; realloc and try again */ - out = zend_string_realloc(out, out->len + CHUNK_SIZE, 0); + out = zend_string_realloc(out, ZSTR_LEN(out) + CHUNK_SIZE, 0); ctx->avail_out = CHUNK_SIZE; - ctx->next_out = (Bytef *) out->val + buffer_used; + ctx->next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; break; } else { goto complete; @@ -972,9 +972,9 @@ PHP_FUNCTION(inflate_add) case Z_BUF_ERROR: if (flush_type == Z_FINISH && ctx->avail_out == 0) { /* more output buffer space needed; realloc and try again */ - out = zend_string_realloc(out, out->len + CHUNK_SIZE, 0); + out = zend_string_realloc(out, ZSTR_LEN(out) + CHUNK_SIZE, 0); ctx->avail_out = CHUNK_SIZE; - ctx->next_out = (Bytef *) out->val + buffer_used; + ctx->next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; break; } else { /* No more input data; we're finished */ @@ -1010,7 +1010,7 @@ PHP_FUNCTION(inflate_add) complete: { out = zend_string_realloc(out, buffer_used, 0); - out->val[buffer_used] = 0; + ZSTR_VAL(out)[buffer_used] = 0; RETURN_STR(out); } } @@ -1162,20 +1162,20 @@ PHP_FUNCTION(deflate_add) out = zend_string_alloc(out_size, 0); ctx->next_in = (Bytef *) in_buf; - ctx->next_out = (Bytef *) out->val; + ctx->next_out = (Bytef *) ZSTR_VAL(out); ctx->avail_in = in_len; - ctx->avail_out = out->len; + ctx->avail_out = ZSTR_LEN(out); status = deflate(ctx, flush_type); switch (status) { case Z_OK: - out->len = (char *) ctx->next_out - out->val; - out->val[out->len] = 0; + ZSTR_LEN(out) = (char *) ctx->next_out - ZSTR_VAL(out); + ZSTR_VAL(out)[ZSTR_LEN(out)] = 0; RETURN_STR(out); break; case Z_STREAM_END: - out->len = (char *) ctx->next_out - out->val; - out->val[out->len] = 0; + ZSTR_LEN(out) = (char *) ctx->next_out - ZSTR_VAL(out); + ZSTR_VAL(out)[ZSTR_LEN(out)] = 0; deflateReset(ctx); RETURN_STR(out); break; @@ -1370,12 +1370,12 @@ static PHP_INI_MH(OnUpdate_zlib_output_compression) return FAILURE; } - if (!strncasecmp(new_value->val, "off", sizeof("off"))) { + if (!strncasecmp(ZSTR_VAL(new_value), "off", sizeof("off"))) { int_value = 0; - } else if (!strncasecmp(new_value->val, "on", sizeof("on"))) { + } else if (!strncasecmp(ZSTR_VAL(new_value), "on", sizeof("on"))) { int_value = 1; } else { - int_value = zend_atoi(new_value->val, new_value->len); + int_value = zend_atoi(ZSTR_VAL(new_value), ZSTR_LEN(new_value)); } ini_value = zend_ini_string("output_handler", sizeof("output_handler"), 0); |