summaryrefslogtreecommitdiff
path: root/ext/soap/php_schema.c
diff options
context:
space:
mode:
authorAaron Piotrowski <aaron@trowski.com>2016-06-10 22:02:23 -0500
committerAaron Piotrowski <aaron@trowski.com>2016-06-10 22:02:23 -0500
commite3c681aa5cc71122a8d2fae42e6513fc413ccac8 (patch)
tree5f1df62f7b666028edb0ee1adf083a52d63df45a /ext/soap/php_schema.c
parentfb4e3085cbaa76eb8f28eebf848a81d1c0190067 (diff)
parent792e89385ca6fc722a03590722eb7745a2374720 (diff)
downloadphp-git-e3c681aa5cc71122a8d2fae42e6513fc413ccac8.tar.gz
Merge branch 'master' into throw-error-in-extensions
Diffstat (limited to 'ext/soap/php_schema.c')
-rw-r--r--ext/soap/php_schema.c45
1 files changed, 21 insertions, 24 deletions
diff --git a/ext/soap/php_schema.c b/ext/soap/php_schema.c
index 4e69ecd198..f417a1e0c9 100644
--- a/ext/soap/php_schema.c
+++ b/ext/soap/php_schema.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
+ | Copyright (c) 1997-2016 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -457,14 +457,13 @@ static int schema_list(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr listType, sdlTypeP
memset(newType, 0, sizeof(sdlType));
{
- smart_str anonymous = {0};
+ char buf[MAX_LENGTH_OF_LONG + 1];
+ char *res = zend_print_long_to_buf(buf + sizeof(buf) - 1, zend_hash_num_elements(sdl->types));
+ char *str = emalloc(sizeof("anonymous") + buf + sizeof(buf) - 1 - res);
- smart_str_appendl(&anonymous, "anonymous", sizeof("anonymous")-1);
- smart_str_append_long(&anonymous, zend_hash_num_elements(sdl->types));
- smart_str_0(&anonymous);
- // TODO: avoid reallocation ???
- newType->name = estrndup(ZSTR_VAL(anonymous.s), ZSTR_LEN(anonymous.s));
- smart_str_free(&anonymous);
+ memcpy(str, "anonymous", sizeof("anonymous")-1);
+ memcpy(str + sizeof("anonymous")-1, res, buf + sizeof(buf) - res);
+ newType->name = str;
}
newType->namens = estrdup((char*)tns->children->content);
@@ -555,14 +554,13 @@ static int schema_union(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr unionType, sdlTyp
memset(newType, 0, sizeof(sdlType));
{
- smart_str anonymous = {0};
-
- smart_str_appendl(&anonymous, "anonymous", sizeof("anonymous")-1);
- smart_str_append_long(&anonymous, zend_hash_num_elements(sdl->types));
- smart_str_0(&anonymous);
- // TODO: avoid reallocation ???
- newType->name = estrndup(ZSTR_VAL(anonymous.s), ZSTR_LEN(anonymous.s));
- smart_str_free(&anonymous);
+ char buf[MAX_LENGTH_OF_LONG + 1];
+ char *res = zend_print_long_to_buf(buf + sizeof(buf) - 1, zend_hash_num_elements(sdl->types));
+ char *str = emalloc(sizeof("anonymous") + buf + sizeof(buf) - 1 - res);
+
+ memcpy(str, "anonymous", sizeof("anonymous")-1);
+ memcpy(str + sizeof("anonymous")-1, res, buf + sizeof(buf) - res);
+ newType->name = str;
}
newType->namens = estrdup((char*)tns->children->content);
@@ -1928,14 +1926,13 @@ static int schema_attribute(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr attrType, sdl
dummy_type = emalloc(sizeof(sdlType));
memset(dummy_type, 0, sizeof(sdlType));
{
- smart_str anonymous = {0};
-
- smart_str_appendl(&anonymous, "anonymous", sizeof("anonymous")-1);
- smart_str_append_long(&anonymous, zend_hash_num_elements(sdl->types));
- smart_str_0(&anonymous);
- // TODO: avoid reallocation ???
- dummy_type->name = estrndup(ZSTR_VAL(anonymous.s), ZSTR_LEN(anonymous.s));
- smart_str_free(&anonymous);
+ char buf[MAX_LENGTH_OF_LONG + 1];
+ char *res = zend_print_long_to_buf(buf + sizeof(buf) - 1, zend_hash_num_elements(sdl->types));
+ char *str = emalloc(sizeof("anonymous") + buf + sizeof(buf) - 1 - res);
+
+ memcpy(str, "anonymous", sizeof("anonymous")-1);
+ memcpy(str + sizeof("anonymous")-1, res, buf + sizeof(buf) - res);
+ dummy_type->name = str;
}
dummy_type->namens = estrdup((char*)tns->children->content);
schema_simpleType(sdl, tns, trav, dummy_type);