WSDL cache was disabled by default (see WSDL_CACHE macro)

WSDL related memory leaks were fixed
This commit is contained in:
Dmitry Stogov 2004-02-06 14:22:33 +00:00
parent 88c1168941
commit 6ae97a5b25
6 changed files with 280 additions and 225 deletions

View file

@ -2600,13 +2600,28 @@ void delete_encoder(void *encode)
{ {
encodePtr t = *((encodePtr*)encode); encodePtr t = *((encodePtr*)encode);
if (t->details.ns) { if (t->details.ns) {
free(t->details.ns); sdl_free(t->details.ns);
} }
if (t->details.type_str) { if (t->details.type_str) {
free(t->details.type_str); sdl_free(t->details.type_str);
} }
if (t->details.map) { if (t->details.map) {
delete_mapping(t->details.map); delete_mapping(t->details.map);
} }
free(t); sdl_free(t);
}
void delete_tmp_encoder(void *encode)
{
encodePtr t = *((encodePtr*)encode);
if (t->details.ns) {
efree(t->details.ns);
}
if (t->details.type_str) {
efree(t->details.type_str);
}
if (t->details.map) {
delete_mapping(t->details.map);
}
efree(t);
} }

View file

@ -215,6 +215,7 @@ encodePtr get_conversion_from_type_ex(HashTable *encoding, xmlNodePtr node, cons
encodePtr get_conversion_from_href_type_ex(HashTable *encoding, const char *type, int len); encodePtr get_conversion_from_href_type_ex(HashTable *encoding, const char *type, int len);
void delete_encoder(void *handle); void delete_encoder(void *handle);
void delete_tmp_encoder(void *encode);
extern encode defaultEncoding[]; extern encode defaultEncoding[];

View file

@ -59,8 +59,8 @@ static encodePtr create_encoder(sdlPtr sdl, sdlTypePtr cur_type, const char *ns,
encodePtr enc, *enc_ptr; encodePtr enc, *enc_ptr;
if (sdl->encoders == NULL) { if (sdl->encoders == NULL) {
sdl->encoders = malloc(sizeof(HashTable)); sdl->encoders = sdl_malloc(sizeof(HashTable));
zend_hash_init(sdl->encoders, 0, NULL, delete_encoder, 1); zend_hash_init(sdl->encoders, 0, NULL, delete_encoder, SDL_PERSISTENT);
} }
smart_str_appends(&nscat, ns); smart_str_appends(&nscat, ns);
smart_str_appendc(&nscat, ':'); smart_str_appendc(&nscat, ':');
@ -69,19 +69,19 @@ static encodePtr create_encoder(sdlPtr sdl, sdlTypePtr cur_type, const char *ns,
if (zend_hash_find(sdl->encoders, nscat.c, nscat.len + 1, (void**)&enc_ptr) == SUCCESS) { if (zend_hash_find(sdl->encoders, nscat.c, nscat.len + 1, (void**)&enc_ptr) == SUCCESS) {
enc = *enc_ptr; enc = *enc_ptr;
if (enc->details.ns) { if (enc->details.ns) {
free(enc->details.ns); sdl_free(enc->details.ns);
} }
if (enc->details.type_str) { if (enc->details.type_str) {
free(enc->details.type_str); sdl_free(enc->details.type_str);
} }
} else { } else {
enc_ptr = NULL; enc_ptr = NULL;
enc = malloc(sizeof(encode)); enc = sdl_malloc(sizeof(encode));
} }
memset(enc, 0, sizeof(encode)); memset(enc, 0, sizeof(encode));
enc->details.ns = strdup(ns); enc->details.ns = sdl_strdup(ns);
enc->details.type_str = strdup(type); enc->details.type_str = sdl_strdup(type);
enc->details.sdl_type = cur_type; enc->details.sdl_type = cur_type;
enc->to_xml = sdl_guess_convert_xml; enc->to_xml = sdl_guess_convert_xml;
enc->to_zval = sdl_guess_convert_zval; enc->to_zval = sdl_guess_convert_zval;
@ -185,8 +185,8 @@ int load_schema(sdlCtx *ctx,xmlNodePtr schema)
xmlAttrPtr tns; xmlAttrPtr tns;
if (!ctx->sdl->types) { if (!ctx->sdl->types) {
ctx->sdl->types = malloc(sizeof(HashTable)); ctx->sdl->types = sdl_malloc(sizeof(HashTable));
zend_hash_init(ctx->sdl->types, 0, NULL, delete_type, 1); zend_hash_init(ctx->sdl->types, 0, NULL, delete_type, SDL_PERSISTENT);
} }
if (!ctx->attributes) { if (!ctx->attributes) {
ctx->attributes = emalloc(sizeof(HashTable)); ctx->attributes = emalloc(sizeof(HashTable));
@ -328,27 +328,27 @@ static int schema_simpleType(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr simpleType,
/* Anonymous type inside <element> or <restriction> */ /* Anonymous type inside <element> or <restriction> */
sdlTypePtr newType, *ptr; sdlTypePtr newType, *ptr;
newType = malloc(sizeof(sdlType)); newType = sdl_malloc(sizeof(sdlType));
memset(newType, 0, sizeof(sdlType)); memset(newType, 0, sizeof(sdlType));
newType->kind = XSD_TYPEKIND_SIMPLE; newType->kind = XSD_TYPEKIND_SIMPLE;
if (name != NULL) { if (name != NULL) {
newType->name = strdup(name->children->content); newType->name = sdl_strdup(name->children->content);
newType->namens = strdup(ns->children->content); newType->namens = sdl_strdup(ns->children->content);
} else { } else {
newType->name = strdup(cur_type->name); newType->name = sdl_strdup(cur_type->name);
newType->namens = strdup(cur_type->namens); newType->namens = sdl_strdup(cur_type->namens);
} }
zend_hash_next_index_insert(sdl->types, &newType, sizeof(sdlTypePtr), (void **)&ptr); zend_hash_next_index_insert(sdl->types, &newType, sizeof(sdlTypePtr), (void **)&ptr);
if (sdl->encoders == NULL) { if (sdl->encoders == NULL) {
sdl->encoders = malloc(sizeof(HashTable)); sdl->encoders = sdl_malloc(sizeof(HashTable));
zend_hash_init(sdl->encoders, 0, NULL, delete_encoder, 1); zend_hash_init(sdl->encoders, 0, NULL, delete_encoder, SDL_PERSISTENT);
} }
cur_type->encode = malloc(sizeof(encode)); cur_type->encode = sdl_malloc(sizeof(encode));
memset(cur_type->encode, 0, sizeof(encode)); memset(cur_type->encode, 0, sizeof(encode));
cur_type->encode->details.ns = strdup(newType->namens); cur_type->encode->details.ns = sdl_strdup(newType->namens);
cur_type->encode->details.type_str = strdup(newType->name); cur_type->encode->details.type_str = sdl_strdup(newType->name);
cur_type->encode->details.sdl_type = *ptr; cur_type->encode->details.sdl_type = *ptr;
cur_type->encode->to_xml = sdl_guess_convert_xml; cur_type->encode->to_xml = sdl_guess_convert_xml;
cur_type->encode->to_zval = sdl_guess_convert_zval; cur_type->encode->to_zval = sdl_guess_convert_zval;
@ -359,18 +359,18 @@ static int schema_simpleType(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr simpleType,
} else if (name != NULL) { } else if (name != NULL) {
sdlTypePtr newType, *ptr; sdlTypePtr newType, *ptr;
newType = malloc(sizeof(sdlType)); newType = sdl_malloc(sizeof(sdlType));
memset(newType, 0, sizeof(sdlType)); memset(newType, 0, sizeof(sdlType));
newType->kind = XSD_TYPEKIND_SIMPLE; newType->kind = XSD_TYPEKIND_SIMPLE;
newType->name = strdup(name->children->content); newType->name = sdl_strdup(name->children->content);
newType->namens = strdup(ns->children->content); newType->namens = sdl_strdup(ns->children->content);
if (cur_type == NULL) { if (cur_type == NULL) {
zend_hash_next_index_insert(sdl->types, &newType, sizeof(sdlTypePtr), (void **)&ptr); zend_hash_next_index_insert(sdl->types, &newType, sizeof(sdlTypePtr), (void **)&ptr);
} else { } else {
if (cur_type->elements == NULL) { if (cur_type->elements == NULL) {
cur_type->elements = malloc(sizeof(HashTable)); cur_type->elements = sdl_malloc(sizeof(HashTable));
zend_hash_init(cur_type->elements, 0, NULL, delete_type, 1); zend_hash_init(cur_type->elements, 0, NULL, delete_type, SDL_PERSISTENT);
} }
zend_hash_update(cur_type->elements, newType->name, strlen(newType->name)+1, &newType, sizeof(sdlTypePtr), (void **)&ptr); zend_hash_update(cur_type->elements, newType->name, strlen(newType->name)+1, &newType, sizeof(sdlTypePtr), (void **)&ptr);
} }
@ -434,17 +434,17 @@ static int schema_list(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr listType, sdlTypeP
if (nsptr != NULL) { if (nsptr != NULL) {
sdlTypePtr newType, *tmp; sdlTypePtr newType, *tmp;
newType = malloc(sizeof(sdlType)); newType = sdl_malloc(sizeof(sdlType));
memset(newType, 0, sizeof(sdlType)); memset(newType, 0, sizeof(sdlType));
newType->name = strdup(type); newType->name = sdl_strdup(type);
newType->namens = strdup(nsptr->href); newType->namens = sdl_strdup(nsptr->href);
newType->encode = get_create_encoder(sdl, newType, (char *)nsptr->href, type); newType->encode = get_create_encoder(sdl, newType, (char *)nsptr->href, type);
if (cur_type->elements == NULL) { if (cur_type->elements == NULL) {
cur_type->elements = malloc(sizeof(HashTable)); cur_type->elements = sdl_malloc(sizeof(HashTable));
zend_hash_init(cur_type->elements, 0, NULL, delete_type, 1); zend_hash_init(cur_type->elements, 0, NULL, delete_type, SDL_PERSISTENT);
} }
zend_hash_next_index_insert(cur_type->elements, &newType, sizeof(sdlTypePtr), (void **)&tmp); zend_hash_next_index_insert(cur_type->elements, &newType, sizeof(sdlTypePtr), (void **)&tmp);
} }
@ -464,15 +464,15 @@ static int schema_list(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr listType, sdlTypeP
php_error(E_ERROR, "SOAP-ERROR: Parsing Schema: element has both 'itemType' attribute and subtype"); php_error(E_ERROR, "SOAP-ERROR: Parsing Schema: element has both 'itemType' attribute and subtype");
} }
newType = malloc(sizeof(sdlType)); newType = sdl_malloc(sizeof(sdlType));
memset(newType, 0, sizeof(sdlType)); memset(newType, 0, sizeof(sdlType));
newType->name = strdup("anonymous"); newType->name = sdl_strdup("anonymous");
newType->namens = strdup(tsn->children->content); newType->namens = sdl_strdup(tsn->children->content);
if (cur_type->elements == NULL) { if (cur_type->elements == NULL) {
cur_type->elements = malloc(sizeof(HashTable)); cur_type->elements = sdl_malloc(sizeof(HashTable));
zend_hash_init(cur_type->elements, 0, NULL, delete_type, 1); zend_hash_init(cur_type->elements, 0, NULL, delete_type, SDL_PERSISTENT);
} }
zend_hash_next_index_insert(cur_type->elements, &newType, sizeof(sdlTypePtr), (void **)&tmp); zend_hash_next_index_insert(cur_type->elements, &newType, sizeof(sdlTypePtr), (void **)&tmp);
@ -521,17 +521,17 @@ static int schema_union(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr unionType, sdlTyp
if (nsptr != NULL) { if (nsptr != NULL) {
sdlTypePtr newType, *tmp; sdlTypePtr newType, *tmp;
newType = malloc(sizeof(sdlType)); newType = sdl_malloc(sizeof(sdlType));
memset(newType, 0, sizeof(sdlType)); memset(newType, 0, sizeof(sdlType));
newType->name = strdup(type); newType->name = sdl_strdup(type);
newType->namens = strdup(nsptr->href); newType->namens = sdl_strdup(nsptr->href);
newType->encode = get_create_encoder(sdl, newType, (char *)nsptr->href, type); newType->encode = get_create_encoder(sdl, newType, (char *)nsptr->href, type);
if (cur_type->elements == NULL) { if (cur_type->elements == NULL) {
cur_type->elements = malloc(sizeof(HashTable)); cur_type->elements = sdl_malloc(sizeof(HashTable));
zend_hash_init(cur_type->elements, 0, NULL, delete_type, 1); zend_hash_init(cur_type->elements, 0, NULL, delete_type, SDL_PERSISTENT);
} }
zend_hash_next_index_insert(cur_type->elements, &newType, sizeof(sdlTypePtr), (void **)&tmp); zend_hash_next_index_insert(cur_type->elements, &newType, sizeof(sdlTypePtr), (void **)&tmp);
} }
@ -556,15 +556,15 @@ static int schema_union(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr unionType, sdlTyp
php_error(E_ERROR, "SOAP-ERROR: Parsing Schema: union has both 'memberTypes' attribute and subtypes"); php_error(E_ERROR, "SOAP-ERROR: Parsing Schema: union has both 'memberTypes' attribute and subtypes");
} }
newType = malloc(sizeof(sdlType)); newType = sdl_malloc(sizeof(sdlType));
memset(newType, 0, sizeof(sdlType)); memset(newType, 0, sizeof(sdlType));
newType->name = strdup("anonymous"); newType->name = sdl_strdup("anonymous");
newType->namens = strdup(tsn->children->content); newType->namens = sdl_strdup(tsn->children->content);
if (cur_type->elements == NULL) { if (cur_type->elements == NULL) {
cur_type->elements = malloc(sizeof(HashTable)); cur_type->elements = sdl_malloc(sizeof(HashTable));
zend_hash_init(cur_type->elements, 0, NULL, delete_type, 1); zend_hash_init(cur_type->elements, 0, NULL, delete_type, SDL_PERSISTENT);
} }
zend_hash_next_index_insert(cur_type->elements, &newType, sizeof(sdlTypePtr), (void **)&tmp); zend_hash_next_index_insert(cur_type->elements, &newType, sizeof(sdlTypePtr), (void **)&tmp);
@ -655,7 +655,7 @@ static int schema_restriction_simpleContent(sdlPtr sdl, xmlAttrPtr tsn, xmlNodeP
} }
if (cur_type->restrictions == NULL) { if (cur_type->restrictions == NULL) {
cur_type->restrictions = malloc(sizeof(sdlRestrictions)); cur_type->restrictions = sdl_malloc(sizeof(sdlRestrictions));
memset(cur_type->restrictions, 0, sizeof(sdlRestrictions)); memset(cur_type->restrictions, 0, sizeof(sdlRestrictions));
} }
@ -696,8 +696,8 @@ static int schema_restriction_simpleContent(sdlPtr sdl, xmlAttrPtr tsn, xmlNodeP
schema_restriction_var_char(trav, &enumval); schema_restriction_var_char(trav, &enumval);
if (cur_type->restrictions->enumeration == NULL) { if (cur_type->restrictions->enumeration == NULL) {
cur_type->restrictions->enumeration = malloc(sizeof(HashTable)); cur_type->restrictions->enumeration = sdl_malloc(sizeof(HashTable));
zend_hash_init(cur_type->restrictions->enumeration, 0, NULL, delete_schema_restriction_var_char, 1); zend_hash_init(cur_type->restrictions->enumeration, 0, NULL, delete_schema_restriction_var_char, SDL_PERSISTENT);
} }
zend_hash_add(cur_type->restrictions->enumeration, enumval->value, strlen(enumval->value)+1, &enumval, sizeof(sdlRestrictionCharPtr), NULL); zend_hash_add(cur_type->restrictions->enumeration, enumval->value, strlen(enumval->value)+1, &enumval, sizeof(sdlRestrictionCharPtr), NULL);
} else { } else {
@ -803,7 +803,7 @@ static int schema_restriction_var_int(xmlNodePtr val, sdlRestrictionIntPtr *valp
xmlAttrPtr fixed, value; xmlAttrPtr fixed, value;
if ((*valptr) == NULL) { if ((*valptr) == NULL) {
(*valptr) = malloc(sizeof(sdlRestrictionInt)); (*valptr) = sdl_malloc(sizeof(sdlRestrictionInt));
} }
memset((*valptr), 0, sizeof(sdlRestrictionInt)); memset((*valptr), 0, sizeof(sdlRestrictionInt));
@ -830,7 +830,7 @@ static int schema_restriction_var_char(xmlNodePtr val, sdlRestrictionCharPtr *va
xmlAttrPtr fixed, value; xmlAttrPtr fixed, value;
if ((*valptr) == NULL) { if ((*valptr) == NULL) {
(*valptr) = malloc(sizeof(sdlRestrictionChar)); (*valptr) = sdl_malloc(sizeof(sdlRestrictionChar));
} }
memset((*valptr), 0, sizeof(sdlRestrictionChar)); memset((*valptr), 0, sizeof(sdlRestrictionChar));
@ -848,7 +848,7 @@ static int schema_restriction_var_char(xmlNodePtr val, sdlRestrictionCharPtr *va
php_error(E_ERROR, "SOAP-ERROR: Parsing Schema: missing restriction value"); php_error(E_ERROR, "SOAP-ERROR: Parsing Schema: missing restriction value");
} }
(*valptr)->value = strdup(value->children->content); (*valptr)->value = sdl_strdup(value->children->content);
return TRUE; return TRUE;
} }
@ -992,10 +992,10 @@ static int schema_all(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr all, sdlTypePtr cur
xmlAttrPtr attr; xmlAttrPtr attr;
sdlContentModelPtr newModel; sdlContentModelPtr newModel;
newModel = malloc(sizeof(sdlContentModel)); newModel = sdl_malloc(sizeof(sdlContentModel));
newModel->kind = XSD_CONTENT_ALL; newModel->kind = XSD_CONTENT_ALL;
newModel->u.content = malloc(sizeof(HashTable)); newModel->u.content = sdl_malloc(sizeof(HashTable));
zend_hash_init(newModel->u.content, 0, NULL, delete_model, 1); zend_hash_init(newModel->u.content, 0, NULL, delete_model, SDL_PERSISTENT);
if (model == NULL) { if (model == NULL) {
cur_type->model = newModel; cur_type->model = newModel;
} else { } else {
@ -1079,17 +1079,17 @@ static int schema_group(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr groupType, sdlTyp
smart_str_appends(&key, type); smart_str_appends(&key, type);
smart_str_0(&key); smart_str_0(&key);
newModel = malloc(sizeof(sdlContentModel)); newModel = sdl_malloc(sizeof(sdlContentModel));
newModel->kind = XSD_CONTENT_GROUP_REF; newModel->kind = XSD_CONTENT_GROUP_REF;
newModel->u.group_ref = estrdup(key.c); newModel->u.group_ref = estrdup(key.c);
if (type) {efree(type);} if (type) {efree(type);}
if (ns) {efree(ns);} if (ns) {efree(ns);}
} else { } else {
newModel = malloc(sizeof(sdlContentModel)); newModel = sdl_malloc(sizeof(sdlContentModel));
newModel->kind = XSD_CONTENT_SEQUENCE; /* will be redefined */ newModel->kind = XSD_CONTENT_SEQUENCE; /* will be redefined */
newModel->u.content = malloc(sizeof(HashTable)); newModel->u.content = sdl_malloc(sizeof(HashTable));
zend_hash_init(newModel->u.content, 0, NULL, delete_model, 1); zend_hash_init(newModel->u.content, 0, NULL, delete_model, SDL_PERSISTENT);
smart_str_appends(&key, ns->children->content); smart_str_appends(&key, ns->children->content);
smart_str_appendc(&key, ':'); smart_str_appendc(&key, ':');
@ -1100,12 +1100,12 @@ static int schema_group(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr groupType, sdlTyp
if (cur_type == NULL) { if (cur_type == NULL) {
sdlTypePtr newType; sdlTypePtr newType;
newType = malloc(sizeof(sdlType)); newType = sdl_malloc(sizeof(sdlType));
memset(newType, 0, sizeof(sdlType)); memset(newType, 0, sizeof(sdlType));
if (sdl->groups == NULL) { if (sdl->groups == NULL) {
sdl->groups = malloc(sizeof(HashTable)); sdl->groups = sdl_malloc(sizeof(HashTable));
zend_hash_init(sdl->groups, 0, NULL, delete_type, 1); zend_hash_init(sdl->groups, 0, NULL, delete_type, SDL_PERSISTENT);
} }
if (zend_hash_add(sdl->groups, key.c, key.len+1, (void**)&newType, sizeof(sdlTypePtr), NULL) != SUCCESS) { if (zend_hash_add(sdl->groups, key.c, key.len+1, (void**)&newType, sizeof(sdlTypePtr), NULL) != SUCCESS) {
php_error(E_ERROR, "SOAP-ERROR: Parsing Schema: group '%s' already defined",key.c); php_error(E_ERROR, "SOAP-ERROR: Parsing Schema: group '%s' already defined",key.c);
@ -1192,10 +1192,10 @@ static int schema_choice(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr choiceType, sdlT
xmlAttrPtr attr; xmlAttrPtr attr;
sdlContentModelPtr newModel; sdlContentModelPtr newModel;
newModel = malloc(sizeof(sdlContentModel)); newModel = sdl_malloc(sizeof(sdlContentModel));
newModel->kind = XSD_CONTENT_CHOICE; newModel->kind = XSD_CONTENT_CHOICE;
newModel->u.content = malloc(sizeof(HashTable)); newModel->u.content = sdl_malloc(sizeof(HashTable));
zend_hash_init(newModel->u.content, 0, NULL, delete_model, 1); zend_hash_init(newModel->u.content, 0, NULL, delete_model, SDL_PERSISTENT);
if (model == NULL) { if (model == NULL) {
cur_type->model = newModel; cur_type->model = newModel;
} else { } else {
@ -1258,10 +1258,10 @@ static int schema_sequence(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr seqType, sdlTy
xmlAttrPtr attr; xmlAttrPtr attr;
sdlContentModelPtr newModel; sdlContentModelPtr newModel;
newModel = malloc(sizeof(sdlContentModel)); newModel = sdl_malloc(sizeof(sdlContentModel));
newModel->kind = XSD_CONTENT_SEQUENCE; newModel->kind = XSD_CONTENT_SEQUENCE;
newModel->u.content = malloc(sizeof(HashTable)); newModel->u.content = sdl_malloc(sizeof(HashTable));
zend_hash_init(newModel->u.content, 0, NULL, delete_model, 1); zend_hash_init(newModel->u.content, 0, NULL, delete_model, SDL_PERSISTENT);
if (model == NULL) { if (model == NULL) {
cur_type->model = newModel; cur_type->model = newModel;
} else { } else {
@ -1383,27 +1383,27 @@ static int schema_complexType(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr compType, s
/* Anonymous type inside <element> */ /* Anonymous type inside <element> */
sdlTypePtr newType, *ptr; sdlTypePtr newType, *ptr;
newType = malloc(sizeof(sdlType)); newType = sdl_malloc(sizeof(sdlType));
memset(newType, 0, sizeof(sdlType)); memset(newType, 0, sizeof(sdlType));
newType->kind = XSD_TYPEKIND_COMPLEX; newType->kind = XSD_TYPEKIND_COMPLEX;
if (name != NULL) { if (name != NULL) {
newType->name = strdup(name->children->content); newType->name = sdl_strdup(name->children->content);
newType->namens = strdup(ns->children->content); newType->namens = sdl_strdup(ns->children->content);
} else { } else {
newType->name = strdup(cur_type->name); newType->name = sdl_strdup(cur_type->name);
newType->namens = strdup(cur_type->namens); newType->namens = sdl_strdup(cur_type->namens);
} }
zend_hash_next_index_insert(sdl->types, &newType, sizeof(sdlTypePtr), (void **)&ptr); zend_hash_next_index_insert(sdl->types, &newType, sizeof(sdlTypePtr), (void **)&ptr);
if (sdl->encoders == NULL) { if (sdl->encoders == NULL) {
sdl->encoders = malloc(sizeof(HashTable)); sdl->encoders = sdl_malloc(sizeof(HashTable));
zend_hash_init(sdl->encoders, 0, NULL, delete_encoder, 1); zend_hash_init(sdl->encoders, 0, NULL, delete_encoder, SDL_PERSISTENT);
} }
cur_type->encode = malloc(sizeof(encode)); cur_type->encode = sdl_malloc(sizeof(encode));
memset(cur_type->encode, 0, sizeof(encode)); memset(cur_type->encode, 0, sizeof(encode));
cur_type->encode->details.ns = strdup(newType->namens); cur_type->encode->details.ns = sdl_strdup(newType->namens);
cur_type->encode->details.type_str = strdup(newType->name); cur_type->encode->details.type_str = sdl_strdup(newType->name);
cur_type->encode->details.sdl_type = *ptr; cur_type->encode->details.sdl_type = *ptr;
cur_type->encode->to_xml = sdl_guess_convert_xml; cur_type->encode->to_xml = sdl_guess_convert_xml;
cur_type->encode->to_zval = sdl_guess_convert_zval; cur_type->encode->to_zval = sdl_guess_convert_zval;
@ -1414,11 +1414,11 @@ static int schema_complexType(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr compType, s
} else if (name) { } else if (name) {
sdlTypePtr newType, *ptr; sdlTypePtr newType, *ptr;
newType = malloc(sizeof(sdlType)); newType = sdl_malloc(sizeof(sdlType));
memset(newType, 0, sizeof(sdlType)); memset(newType, 0, sizeof(sdlType));
newType->kind = XSD_TYPEKIND_COMPLEX; newType->kind = XSD_TYPEKIND_COMPLEX;
newType->name = strdup(name->children->content); newType->name = sdl_strdup(name->children->content);
newType->namens = strdup(ns->children->content); newType->namens = sdl_strdup(ns->children->content);
zend_hash_next_index_insert(sdl->types, &newType, sizeof(sdlTypePtr), (void **)&ptr); zend_hash_next_index_insert(sdl->types, &newType, sizeof(sdlTypePtr), (void **)&ptr);
@ -1517,7 +1517,7 @@ static int schema_element(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr element, sdlTyp
sdlTypePtr newType; sdlTypePtr newType;
smart_str key = {0}; smart_str key = {0};
newType = malloc(sizeof(sdlType)); newType = sdl_malloc(sizeof(sdlType));
memset(newType, 0, sizeof(sdlType)); memset(newType, 0, sizeof(sdlType));
if (ref) { if (ref) {
@ -1530,26 +1530,26 @@ static int schema_element(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr element, sdlTyp
if (nsptr != NULL) { if (nsptr != NULL) {
smart_str_appends(&nscat, nsptr->href); smart_str_appends(&nscat, nsptr->href);
smart_str_appendc(&nscat, ':'); smart_str_appendc(&nscat, ':');
newType->namens = strdup(nsptr->href); newType->namens = sdl_strdup(nsptr->href);
} }
smart_str_appends(&nscat, type); smart_str_appends(&nscat, type);
newType->name = strdup(type); newType->name = sdl_strdup(type);
smart_str_0(&nscat); smart_str_0(&nscat);
if (type) {efree(type);} if (type) {efree(type);}
if (ns) {efree(ns);} if (ns) {efree(ns);}
newType->ref = estrdup(nscat.c); newType->ref = estrdup(nscat.c);
smart_str_free(&nscat); smart_str_free(&nscat);
} else { } else {
newType->name = strdup(name->children->content); newType->name = sdl_strdup(name->children->content);
newType->namens = strdup(ns->children->content); newType->namens = sdl_strdup(ns->children->content);
} }
newType->nillable = FALSE; newType->nillable = FALSE;
if (cur_type == NULL) { if (cur_type == NULL) {
if (sdl->elements == NULL) { if (sdl->elements == NULL) {
sdl->elements = malloc(sizeof(HashTable)); sdl->elements = sdl_malloc(sizeof(HashTable));
zend_hash_init(sdl->elements, 0, NULL, delete_type, 1); zend_hash_init(sdl->elements, 0, NULL, delete_type, SDL_PERSISTENT);
} }
addHash = sdl->elements; addHash = sdl->elements;
smart_str_appends(&key, newType->namens); smart_str_appends(&key, newType->namens);
@ -1557,8 +1557,8 @@ static int schema_element(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr element, sdlTyp
smart_str_appends(&key, newType->name); smart_str_appends(&key, newType->name);
} else { } else {
if (cur_type->elements == NULL) { if (cur_type->elements == NULL) {
cur_type->elements = malloc(sizeof(HashTable)); cur_type->elements = sdl_malloc(sizeof(HashTable));
zend_hash_init(cur_type->elements, 0, NULL, delete_type, 1); zend_hash_init(cur_type->elements, 0, NULL, delete_type, SDL_PERSISTENT);
} }
addHash = cur_type->elements; addHash = cur_type->elements;
smart_str_appends(&key, newType->name); smart_str_appends(&key, newType->name);
@ -1575,7 +1575,7 @@ static int schema_element(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr element, sdlTyp
smart_str_free(&key); smart_str_free(&key);
if (model != NULL) { if (model != NULL) {
sdlContentModelPtr newModel = malloc(sizeof(sdlContentModel)); sdlContentModelPtr newModel = sdl_malloc(sizeof(sdlContentModel));
newModel->kind = XSD_CONTENT_ELEMENT; newModel->kind = XSD_CONTENT_ELEMENT;
newModel->u.element = newType; newModel->u.element = newType;
@ -1625,7 +1625,7 @@ static int schema_element(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr element, sdlTyp
if (ref != NULL) { if (ref != NULL) {
php_error(E_ERROR, "SOAP-ERROR: Parsing Schema: element has both 'ref' and 'fixed' attributes"); php_error(E_ERROR, "SOAP-ERROR: Parsing Schema: element has both 'ref' and 'fixed' attributes");
} }
cur_type->fixed = strdup(attr->children->content); cur_type->fixed = sdl_strdup(attr->children->content);
} }
attr = get_attribute(attrs, "default"); attr = get_attribute(attrs, "default");
@ -1635,7 +1635,7 @@ static int schema_element(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr element, sdlTyp
} else if (ref != NULL) { } else if (ref != NULL) {
php_error(E_ERROR, "SOAP-ERROR: Parsing Schema: element has both 'default' and 'fixed' attributes"); php_error(E_ERROR, "SOAP-ERROR: Parsing Schema: element has both 'default' and 'fixed' attributes");
} }
cur_type->def = strdup(attr->children->content); cur_type->def = sdl_strdup(attr->children->content);
} }
/* type = QName */ /* type = QName */
@ -1724,7 +1724,7 @@ static int schema_attribute(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr attrType, sdl
HashTable *addHash; HashTable *addHash;
smart_str key = {0}; smart_str key = {0};
newAttr = malloc(sizeof(sdlAttribute)); newAttr = sdl_malloc(sizeof(sdlAttribute));
memset(newAttr, 0, sizeof(sdlAttribute)); memset(newAttr, 0, sizeof(sdlAttribute));
if (ref) { if (ref) {
@ -1761,8 +1761,8 @@ static int schema_attribute(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr attrType, sdl
addHash = ctx->attributes; addHash = ctx->attributes;
} else { } else {
if (cur_type->attributes == NULL) { if (cur_type->attributes == NULL) {
cur_type->attributes = malloc(sizeof(HashTable)); cur_type->attributes = sdl_malloc(sizeof(HashTable));
zend_hash_init(cur_type->attributes, 0, NULL, delete_attribute, 1); zend_hash_init(cur_type->attributes, 0, NULL, delete_attribute, SDL_PERSISTENT);
} }
addHash = cur_type->attributes; addHash = cur_type->attributes;
} }
@ -1796,9 +1796,9 @@ static int schema_attribute(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr attrType, sdl
attr = attrType->properties; attr = attrType->properties;
while (attr != NULL) { while (attr != NULL) {
if (attr_is_equal_ex(attr, "default", SCHEMA_NAMESPACE)) { if (attr_is_equal_ex(attr, "default", SCHEMA_NAMESPACE)) {
newAttr->def = strdup(attr->children->content); newAttr->def = sdl_strdup(attr->children->content);
} else if (attr_is_equal_ex(attr, "fixed", SCHEMA_NAMESPACE)) { } else if (attr_is_equal_ex(attr, "fixed", SCHEMA_NAMESPACE)) {
newAttr->fixed = strdup(attr->children->content); newAttr->fixed = sdl_strdup(attr->children->content);
} else if (attr_is_equal_ex(attr, "form", SCHEMA_NAMESPACE)) { } else if (attr_is_equal_ex(attr, "form", SCHEMA_NAMESPACE)) {
if (strncmp(attr->children->content,"qualified",sizeof("qualified")) == 0) { if (strncmp(attr->children->content,"qualified",sizeof("qualified")) == 0) {
newAttr->form = XSD_FORM_QUALIFIED; newAttr->form = XSD_FORM_QUALIFIED;
@ -1810,7 +1810,7 @@ static int schema_attribute(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr attrType, sdl
} else if (attr_is_equal_ex(attr, "id", SCHEMA_NAMESPACE)) { } else if (attr_is_equal_ex(attr, "id", SCHEMA_NAMESPACE)) {
/* skip */ /* skip */
} else if (attr_is_equal_ex(attr, "name", SCHEMA_NAMESPACE)) { } else if (attr_is_equal_ex(attr, "name", SCHEMA_NAMESPACE)) {
newAttr->name = strdup(attr->children->content); newAttr->name = sdl_strdup(attr->children->content);
} else if (attr_is_equal_ex(attr, "ref", SCHEMA_NAMESPACE)) { } else if (attr_is_equal_ex(attr, "ref", SCHEMA_NAMESPACE)) {
/* already processed */ /* already processed */
} else if (attr_is_equal_ex(attr, "type", SCHEMA_NAMESPACE)) { } else if (attr_is_equal_ex(attr, "type", SCHEMA_NAMESPACE)) {
@ -1834,22 +1834,22 @@ static int schema_attribute(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr attrType, sdl
xmlNsPtr nsptr; xmlNsPtr nsptr;
char *value, *ns; char *value, *ns;
ext = malloc(sizeof(sdlExtraAttribute)); ext = sdl_malloc(sizeof(sdlExtraAttribute));
memset(ext, 0, sizeof(sdlExtraAttribute)); memset(ext, 0, sizeof(sdlExtraAttribute));
parse_namespace(attr->children->content, &value, &ns); parse_namespace(attr->children->content, &value, &ns);
nsptr = xmlSearchNs(attr->doc, attr->parent, ns); nsptr = xmlSearchNs(attr->doc, attr->parent, ns);
if (nsptr) { if (nsptr) {
ext->ns = strdup(nsptr->href); ext->ns = sdl_strdup(nsptr->href);
ext->val = strdup(value); ext->val = sdl_strdup(value);
} else { } else {
ext->val = strdup(attr->children->content); ext->val = sdl_strdup(attr->children->content);
} }
if (ns) {efree(ns);} if (ns) {efree(ns);}
efree(value); efree(value);
if (!newAttr->extraAttributes) { if (!newAttr->extraAttributes) {
newAttr->extraAttributes = malloc(sizeof(HashTable)); newAttr->extraAttributes = sdl_malloc(sizeof(HashTable));
zend_hash_init(newAttr->extraAttributes, 0, NULL, delete_extra_attribute, 1); zend_hash_init(newAttr->extraAttributes, 0, NULL, delete_extra_attribute, SDL_PERSISTENT);
} }
smart_str_appends(&key2, nsPtr->href); smart_str_appends(&key2, nsPtr->href);
@ -1876,10 +1876,10 @@ static int schema_attribute(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr attrType, sdl
} else if (type != NULL) { } else if (type != NULL) {
php_error(E_ERROR, "SOAP-ERROR: Parsing Schema: attribute has both 'type' attribute and subtype"); php_error(E_ERROR, "SOAP-ERROR: Parsing Schema: attribute has both 'type' attribute and subtype");
} }
dummy_type = malloc(sizeof(sdlType)); dummy_type = sdl_malloc(sizeof(sdlType));
memset(dummy_type, 0, sizeof(sdlType)); memset(dummy_type, 0, sizeof(sdlType));
dummy_type->name = strdup("anonymous"); dummy_type->name = sdl_strdup("anonymous");
dummy_type->namens = strdup(tsn->children->content); dummy_type->namens = sdl_strdup(tsn->children->content);
schema_simpleType(sdl, tsn, trav, dummy_type); schema_simpleType(sdl, tsn, trav, dummy_type);
newAttr->encode = dummy_type->encode; newAttr->encode = dummy_type->encode;
delete_type(&dummy_type); delete_type(&dummy_type);
@ -1912,10 +1912,10 @@ static int schema_attributeGroup(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr attrGrou
if (ns == NULL) { if (ns == NULL) {
ns = tsn; ns = tsn;
} }
newType = malloc(sizeof(sdlType)); newType = sdl_malloc(sizeof(sdlType));
memset(newType, 0, sizeof(sdlType)); memset(newType, 0, sizeof(sdlType));
newType->name = strdup(name->children->content); newType->name = sdl_strdup(name->children->content);
newType->namens = strdup(ns->children->content); newType->namens = sdl_strdup(ns->children->content);
smart_str_appends(&key, newType->namens); smart_str_appends(&key, newType->namens);
smart_str_appendc(&key, ':'); smart_str_appendc(&key, ':');
@ -1934,10 +1934,10 @@ static int schema_attributeGroup(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr attrGrou
xmlNsPtr nsptr; xmlNsPtr nsptr;
if (cur_type->attributes == NULL) { if (cur_type->attributes == NULL) {
cur_type->attributes = malloc(sizeof(HashTable)); cur_type->attributes = sdl_malloc(sizeof(HashTable));
zend_hash_init(cur_type->attributes, 0, NULL, delete_attribute, 1); zend_hash_init(cur_type->attributes, 0, NULL, delete_attribute, SDL_PERSISTENT);
} }
newAttr = malloc(sizeof(sdlAttribute)); newAttr = sdl_malloc(sizeof(sdlAttribute));
memset(newAttr, 0, sizeof(sdlAttribute)); memset(newAttr, 0, sizeof(sdlAttribute));
parse_namespace(ref->children->content, &group_name, &ns); parse_namespace(ref->children->content, &group_name, &ns);
@ -1995,14 +1995,14 @@ static void copy_extra_attribute(void *attribute)
sdlExtraAttributePtr *attr = (sdlExtraAttributePtr*)attribute; sdlExtraAttributePtr *attr = (sdlExtraAttributePtr*)attribute;
sdlExtraAttributePtr new_attr; sdlExtraAttributePtr new_attr;
new_attr = malloc(sizeof(sdlExtraAttribute)); new_attr = sdl_malloc(sizeof(sdlExtraAttribute));
memcpy(new_attr, *attr, sizeof(sdlExtraAttribute)); memcpy(new_attr, *attr, sizeof(sdlExtraAttribute));
*attr = new_attr; *attr = new_attr;
if (new_attr->ns) { if (new_attr->ns) {
new_attr->ns = strdup(new_attr->ns); new_attr->ns = sdl_strdup(new_attr->ns);
} }
if (new_attr->val) { if (new_attr->val) {
new_attr->val = strdup(new_attr->val); new_attr->val = sdl_strdup(new_attr->val);
} }
} }
@ -2015,13 +2015,13 @@ static void schema_attribute_fixup(sdlCtx *ctx, sdlAttributePtr attr)
if (zend_hash_find(ctx->attributes, attr->ref, strlen(attr->ref)+1, (void**)&tmp) == SUCCESS) { if (zend_hash_find(ctx->attributes, attr->ref, strlen(attr->ref)+1, (void**)&tmp) == SUCCESS) {
schema_attribute_fixup(ctx, *tmp); schema_attribute_fixup(ctx, *tmp);
if ((*tmp)->name != NULL && attr->name == NULL) { if ((*tmp)->name != NULL && attr->name == NULL) {
attr->name = strdup((*tmp)->name); attr->name = sdl_strdup((*tmp)->name);
} }
if ((*tmp)->def != NULL && attr->def == NULL) { if ((*tmp)->def != NULL && attr->def == NULL) {
attr->def = strdup((*tmp)->def); attr->def = sdl_strdup((*tmp)->def);
} }
if ((*tmp)->fixed != NULL && attr->fixed == NULL) { if ((*tmp)->fixed != NULL && attr->fixed == NULL) {
attr->fixed = strdup((*tmp)->fixed); attr->fixed = sdl_strdup((*tmp)->fixed);
} }
if (attr->form == XSD_FORM_DEFAULT) { if (attr->form == XSD_FORM_DEFAULT) {
attr->form = (*tmp)->form; attr->form = (*tmp)->form;
@ -2032,8 +2032,8 @@ static void schema_attribute_fixup(sdlCtx *ctx, sdlAttributePtr attr)
if ((*tmp)->extraAttributes != NULL) { if ((*tmp)->extraAttributes != NULL) {
xmlNodePtr node; xmlNodePtr node;
attr->extraAttributes = malloc(sizeof(HashTable)); attr->extraAttributes = sdl_malloc(sizeof(HashTable));
zend_hash_init(attr->extraAttributes, 0, NULL, delete_extra_attribute, 1); zend_hash_init(attr->extraAttributes, 0, NULL, delete_extra_attribute, SDL_PERSISTENT);
zend_hash_copy(attr->extraAttributes, (*tmp)->extraAttributes, copy_extra_attribute, &node, sizeof(xmlNodePtr)); zend_hash_copy(attr->extraAttributes, (*tmp)->extraAttributes, copy_extra_attribute, &node, sizeof(xmlNodePtr));
} }
attr->encode = (*tmp)->encode; attr->encode = (*tmp)->encode;
@ -2042,7 +2042,7 @@ static void schema_attribute_fixup(sdlCtx *ctx, sdlAttributePtr attr)
if (attr->name == NULL && attr->ref != NULL) { if (attr->name == NULL && attr->ref != NULL) {
char *name, *ns; char *name, *ns;
parse_namespace(attr->ref, &name, &ns); parse_namespace(attr->ref, &name, &ns);
attr->name = strdup(name); attr->name = sdl_strdup(name);
if (name) {efree(name);} if (name) {efree(name);}
if (ns) {efree(ns);} if (ns) {efree(ns);}
} }
@ -2069,15 +2069,15 @@ static void schema_attributegroup_fixup(sdlCtx *ctx, sdlAttributePtr attr, HashT
schema_attribute_fixup(ctx,*tmp_attr); schema_attribute_fixup(ctx,*tmp_attr);
newAttr = malloc(sizeof(sdlAttribute)); newAttr = sdl_malloc(sizeof(sdlAttribute));
memcpy(newAttr, *tmp_attr, sizeof(sdlAttribute)); memcpy(newAttr, *tmp_attr, sizeof(sdlAttribute));
if (newAttr->def) {newAttr->def = strdup(newAttr->def);} if (newAttr->def) {newAttr->def = sdl_strdup(newAttr->def);}
if (newAttr->fixed) {newAttr->fixed = strdup(newAttr->fixed);} if (newAttr->fixed) {newAttr->fixed = sdl_strdup(newAttr->fixed);}
if (newAttr->name) {newAttr->name = strdup(newAttr->name);} if (newAttr->name) {newAttr->name = sdl_strdup(newAttr->name);}
if (newAttr->extraAttributes) { if (newAttr->extraAttributes) {
xmlNodePtr node; xmlNodePtr node;
HashTable *ht = malloc(sizeof(HashTable)); HashTable *ht = sdl_malloc(sizeof(HashTable));
zend_hash_init(ht, 0, NULL, delete_extra_attribute, 1); zend_hash_init(ht, 0, NULL, delete_extra_attribute, SDL_PERSISTENT);
zend_hash_copy(ht, newAttr->extraAttributes, copy_extra_attribute, &node, sizeof(xmlNodePtr)); zend_hash_copy(ht, newAttr->extraAttributes, copy_extra_attribute, &node, sizeof(xmlNodePtr));
newAttr->extraAttributes = ht; newAttr->extraAttributes = ht;
} }
@ -2241,37 +2241,40 @@ static void delete_model(void *handle)
case XSD_CONTENT_ALL: case XSD_CONTENT_ALL:
case XSD_CONTENT_CHOICE: case XSD_CONTENT_CHOICE:
zend_hash_destroy(tmp->u.content); zend_hash_destroy(tmp->u.content);
free(tmp->u.content); sdl_free(tmp->u.content);
break; break;
case XSD_CONTENT_GROUP_REF: case XSD_CONTENT_GROUP_REF:
efree(tmp->u.group_ref); efree(tmp->u.group_ref);
break; break;
} }
free(tmp); sdl_free(tmp);
} }
static void delete_type(void *data) static void delete_type(void *data)
{ {
sdlTypePtr type = *((sdlTypePtr*)data); sdlTypePtr type = *((sdlTypePtr*)data);
if (type->name) { if (type->name) {
free(type->name); sdl_free(type->name);
} }
if (type->namens) { if (type->namens) {
free(type->namens); sdl_free(type->namens);
} }
if (type->def) { if (type->def) {
free(type->def); sdl_free(type->def);
} }
if (type->fixed) { if (type->fixed) {
free(type->fixed); sdl_free(type->fixed);
} }
if (type->elements) { if (type->elements) {
zend_hash_destroy(type->elements); zend_hash_destroy(type->elements);
free(type->elements); sdl_free(type->elements);
} }
if (type->attributes) { if (type->attributes) {
zend_hash_destroy(type->attributes); zend_hash_destroy(type->attributes);
free(type->attributes); sdl_free(type->attributes);
}
if (type->model) {
delete_model((void**)&type->model);
} }
if (type->restrictions) { if (type->restrictions) {
delete_restriction_var_int(&type->restrictions->minExclusive); delete_restriction_var_int(&type->restrictions->minExclusive);
@ -2287,11 +2290,11 @@ static void delete_type(void *data)
delete_schema_restriction_var_char(&type->restrictions->pattern); delete_schema_restriction_var_char(&type->restrictions->pattern);
if (type->restrictions->enumeration) { if (type->restrictions->enumeration) {
zend_hash_destroy(type->restrictions->enumeration); zend_hash_destroy(type->restrictions->enumeration);
free(type->restrictions->enumeration); sdl_free(type->restrictions->enumeration);
} }
free(type->restrictions); sdl_free(type->restrictions);
} }
free(type); sdl_free(type);
} }
static void delete_extra_attribute(void *attribute) static void delete_extra_attribute(void *attribute)
@ -2299,12 +2302,12 @@ static void delete_extra_attribute(void *attribute)
sdlExtraAttributePtr attr = *((sdlExtraAttributePtr*)attribute); sdlExtraAttributePtr attr = *((sdlExtraAttributePtr*)attribute);
if (attr->ns) { if (attr->ns) {
free(attr->ns); sdl_free(attr->ns);
} }
if (attr->val) { if (attr->val) {
free(attr->val); sdl_free(attr->val);
} }
free(attr); sdl_free(attr);
} }
static void delete_attribute(void *attribute) static void delete_attribute(void *attribute)
@ -2312,29 +2315,29 @@ static void delete_attribute(void *attribute)
sdlAttributePtr attr = *((sdlAttributePtr*)attribute); sdlAttributePtr attr = *((sdlAttributePtr*)attribute);
if (attr->def) { if (attr->def) {
free(attr->def); sdl_free(attr->def);
} }
if (attr->fixed) { if (attr->fixed) {
free(attr->fixed); sdl_free(attr->fixed);
} }
if (attr->name) { if (attr->name) {
free(attr->name); sdl_free(attr->name);
} }
if (attr->ref) { if (attr->ref) {
free(attr->ref); sdl_free(attr->ref);
} }
if (attr->extraAttributes) { if (attr->extraAttributes) {
zend_hash_destroy(attr->extraAttributes); zend_hash_destroy(attr->extraAttributes);
free(attr->extraAttributes); sdl_free(attr->extraAttributes);
} }
free(attr); sdl_free(attr);
} }
static void delete_restriction_var_int(void *rvi) static void delete_restriction_var_int(void *rvi)
{ {
sdlRestrictionIntPtr ptr = *((sdlRestrictionIntPtr*)rvi); sdlRestrictionIntPtr ptr = *((sdlRestrictionIntPtr*)rvi);
if (ptr) { if (ptr) {
free(ptr); sdl_free(ptr);
} }
} }
@ -2343,8 +2346,8 @@ static void delete_schema_restriction_var_char(void *srvc)
sdlRestrictionCharPtr ptr = *((sdlRestrictionCharPtr*)srvc); sdlRestrictionCharPtr ptr = *((sdlRestrictionCharPtr*)srvc);
if (ptr) { if (ptr) {
if (ptr->value) { if (ptr->value) {
free(ptr->value); sdl_free(ptr->value);
} }
free(ptr); sdl_free(ptr);
} }
} }

View file

@ -175,7 +175,7 @@ static void load_wsdl_ex(char *struri, sdlCtx *ctx, int include)
if (!include) { if (!include) {
targetNamespace = get_attribute(definitions->properties, "targetNamespace"); targetNamespace = get_attribute(definitions->properties, "targetNamespace");
if (targetNamespace) { if (targetNamespace) {
tmpsdl->target_ns = strdup(targetNamespace->children->content); tmpsdl->target_ns = sdl_strdup(targetNamespace->children->content);
} }
} }
@ -268,12 +268,12 @@ static void wsdl_soap_binding_body(sdlCtx* ctx, xmlNodePtr node, char* wsdl_soap
tmp = get_attribute(body->properties, "namespace"); tmp = get_attribute(body->properties, "namespace");
if (tmp) { if (tmp) {
binding->ns = strdup(tmp->children->content); binding->ns = sdl_strdup(tmp->children->content);
} }
tmp = get_attribute(body->properties, "parts"); tmp = get_attribute(body->properties, "parts");
if (tmp) { if (tmp) {
binding->parts = strdup(tmp->children->content); binding->parts = sdl_strdup(tmp->children->content);
} }
if (binding->use == SOAP_ENCODED) { if (binding->use == SOAP_ENCODED) {
@ -285,7 +285,7 @@ static void wsdl_soap_binding_body(sdlCtx* ctx, xmlNodePtr node, char* wsdl_soap
} else if (tmp == NULL) { } else if (tmp == NULL) {
php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Unspecified encodingStyle"); php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Unspecified encodingStyle");
} else { } else {
binding->encodingStyle = strdup(tmp->children->content); binding->encodingStyle = sdl_strdup(tmp->children->content);
} }
} }
} }
@ -319,9 +319,9 @@ static void wsdl_soap_binding_body(sdlCtx* ctx, xmlNodePtr node, char* wsdl_soap
php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Missing part '%s' in <message>",tmp->children->content); php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Missing part '%s' in <message>",tmp->children->content);
} }
h = malloc(sizeof(sdlSoapBindingFunctionHeader)); h = sdl_malloc(sizeof(sdlSoapBindingFunctionHeader));
memset(h, 0, sizeof(sdlSoapBindingFunctionHeader)); memset(h, 0, sizeof(sdlSoapBindingFunctionHeader));
h->name = strdup(tmp->children->content); h->name = sdl_strdup(tmp->children->content);
tmp = get_attribute(part->properties, "type"); tmp = get_attribute(part->properties, "type");
if (tmp != NULL) { if (tmp != NULL) {
@ -345,7 +345,7 @@ static void wsdl_soap_binding_body(sdlCtx* ctx, xmlNodePtr node, char* wsdl_soap
tmp = get_attribute(header->properties, "namespace"); tmp = get_attribute(header->properties, "namespace");
if (tmp) { if (tmp) {
h->ns = strdup(tmp->children->content); h->ns = sdl_strdup(tmp->children->content);
} }
if (h->use == SOAP_ENCODED) { if (h->use == SOAP_ENCODED) {
@ -357,13 +357,13 @@ static void wsdl_soap_binding_body(sdlCtx* ctx, xmlNodePtr node, char* wsdl_soap
} else if (tmp == NULL) { } else if (tmp == NULL) {
php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Unspecified encodingStyle"); php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Unspecified encodingStyle");
} else { } else {
h->encodingStyle = strdup(tmp->children->content); h->encodingStyle = sdl_strdup(tmp->children->content);
} }
} }
if (binding->headers == NULL) { if (binding->headers == NULL) {
binding->headers = malloc(sizeof(HashTable)); binding->headers = sdl_malloc(sizeof(HashTable));
zend_hash_init(binding->headers, 0, NULL, delete_header, 1); zend_hash_init(binding->headers, 0, NULL, delete_header, SDL_PERSISTENT);
} }
if (h->ns) { if (h->ns) {
@ -395,15 +395,15 @@ static HashTable* wsdl_message(sdlCtx *ctx, char* message_name)
if (ctype) {efree(ctype);} if (ctype) {efree(ctype);}
if (ns) {efree(ns);} if (ns) {efree(ns);}
parameters = malloc(sizeof(HashTable)); parameters = sdl_malloc(sizeof(HashTable));
zend_hash_init(parameters, 0, NULL, delete_paramater, 1); zend_hash_init(parameters, 0, NULL, delete_paramater, SDL_PERSISTENT);
trav = message->children; trav = message->children;
FOREACHNODE(trav, "part", part) { FOREACHNODE(trav, "part", part) {
xmlAttrPtr element, type, name; xmlAttrPtr element, type, name;
sdlParamPtr param; sdlParamPtr param;
param = malloc(sizeof(sdlParam)); param = sdl_malloc(sizeof(sdlParam));
memset(param,0,sizeof(sdlParam)); memset(param,0,sizeof(sdlParam));
param->order = 0; param->order = 0;
@ -412,7 +412,7 @@ static HashTable* wsdl_message(sdlCtx *ctx, char* message_name)
php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No name associated with <part> '%s'", message->name); php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No name associated with <part> '%s'", message->name);
} }
param->paramName = strdup(name->children->content); param->paramName = sdl_strdup(name->children->content);
type = get_attribute(part->properties, "type"); type = get_attribute(part->properties, "type");
if (type != NULL) { if (type != NULL) {
@ -439,10 +439,10 @@ static sdlPtr load_wsdl(char *struri)
int i,n; int i,n;
memset(&ctx,0,sizeof(ctx)); memset(&ctx,0,sizeof(ctx));
ctx.sdl = malloc(sizeof(sdl)); ctx.sdl = sdl_malloc(sizeof(sdl));
memset(ctx.sdl, 0, sizeof(sdl)); memset(ctx.sdl, 0, sizeof(sdl));
ctx.sdl->source = strdup(struri); ctx.sdl->source = sdl_strdup(struri);
zend_hash_init(&ctx.sdl->functions, 0, NULL, delete_function, 1); zend_hash_init(&ctx.sdl->functions, 0, NULL, delete_function, SDL_PERSISTENT);
zend_hash_init(&ctx.docs, 0, NULL, delete_document, 0); zend_hash_init(&ctx.docs, 0, NULL, delete_document, 0);
zend_hash_init(&ctx.messages, 0, NULL, NULL, 0); zend_hash_init(&ctx.messages, 0, NULL, NULL, 0);
@ -472,7 +472,7 @@ static sdlPtr load_wsdl(char *struri)
sdlBindingPtr tmpbinding; sdlBindingPtr tmpbinding;
char *wsdl_soap_namespace = NULL; char *wsdl_soap_namespace = NULL;
tmpbinding = malloc(sizeof(sdlBinding)); tmpbinding = sdl_malloc(sizeof(sdlBinding));
memset(tmpbinding, 0, sizeof(sdlBinding)); memset(tmpbinding, 0, sizeof(sdlBinding));
bindingAttr = get_attribute(port->properties, "binding"); bindingAttr = get_attribute(port->properties, "binding");
@ -491,7 +491,7 @@ static sdlPtr load_wsdl(char *struri)
php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No location associated with <port>"); php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No location associated with <port>");
} }
tmpbinding->location = strdup(location->children->content); tmpbinding->location = sdl_strdup(location->children->content);
if (address->ns) { if (address->ns) {
if (!strncmp(address->ns->href, WSDL_SOAP11_NAMESPACE, sizeof(WSDL_SOAP11_NAMESPACE))) { if (!strncmp(address->ns->href, WSDL_SOAP11_NAMESPACE, sizeof(WSDL_SOAP11_NAMESPACE))) {
@ -528,7 +528,7 @@ static sdlPtr load_wsdl(char *struri)
xmlNodePtr soapBindingNode; xmlNodePtr soapBindingNode;
xmlAttrPtr tmp; xmlAttrPtr tmp;
soapBinding = malloc(sizeof(sdlSoapBinding)); soapBinding = sdl_malloc(sizeof(sdlSoapBinding));
memset(soapBinding, 0, sizeof(sdlSoapBinding)); memset(soapBinding, 0, sizeof(sdlSoapBinding));
soapBinding->style = SOAP_DOCUMENT; soapBinding->style = SOAP_DOCUMENT;
@ -544,7 +544,7 @@ static sdlPtr load_wsdl(char *struri)
if (strncmp(tmp->children->content, WSDL_HTTP_TRANSPORT, sizeof(WSDL_HTTP_TRANSPORT))) { if (strncmp(tmp->children->content, WSDL_HTTP_TRANSPORT, sizeof(WSDL_HTTP_TRANSPORT))) {
php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: PHP-SOAP doesn't support transport '%s'", tmp->children->content); php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: PHP-SOAP doesn't support transport '%s'", tmp->children->content);
} }
soapBinding->transport = strdup(tmp->children->content); soapBinding->transport = sdl_strdup(tmp->children->content);
} }
} }
tmpbinding->bindingAttributes = (void *)soapBinding; tmpbinding->bindingAttributes = (void *)soapBinding;
@ -554,7 +554,7 @@ static sdlPtr load_wsdl(char *struri)
if (name == NULL) { if (name == NULL) {
php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Missing 'name' attribute for <binding>"); php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Missing 'name' attribute for <binding>");
} }
tmpbinding->name = strdup(name->children->content); tmpbinding->name = sdl_strdup(name->children->content);
type = get_attribute(binding->properties, "type"); type = get_attribute(binding->properties, "type");
if (type == NULL) { if (type == NULL) {
@ -586,8 +586,8 @@ static sdlPtr load_wsdl(char *struri)
php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Missing <portType>/<operation> with name '%s'", op_name->children->content); php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Missing <portType>/<operation> with name '%s'", op_name->children->content);
} }
function = malloc(sizeof(sdlFunction)); function = sdl_malloc(sizeof(sdlFunction));
function->functionName = strdup(op_name->children->content); function->functionName = sdl_strdup(op_name->children->content);
function->requestParameters = NULL; function->requestParameters = NULL;
function->responseParameters = NULL; function->responseParameters = NULL;
function->responseName = NULL; function->responseName = NULL;
@ -600,7 +600,7 @@ static sdlPtr load_wsdl(char *struri)
xmlNodePtr soapOperation; xmlNodePtr soapOperation;
xmlAttrPtr tmp; xmlAttrPtr tmp;
soapFunctionBinding = malloc(sizeof(sdlSoapBindingFunction)); soapFunctionBinding = sdl_malloc(sizeof(sdlSoapBindingFunction));
memset(soapFunctionBinding, 0, sizeof(sdlSoapBindingFunction)); memset(soapFunctionBinding, 0, sizeof(sdlSoapBindingFunction));
soapBinding = (sdlSoapBindingPtr)tmpbinding->bindingAttributes; soapBinding = (sdlSoapBindingPtr)tmpbinding->bindingAttributes;
soapFunctionBinding->style = soapBinding->style; soapFunctionBinding->style = soapBinding->style;
@ -609,7 +609,7 @@ static sdlPtr load_wsdl(char *struri)
if (soapOperation) { if (soapOperation) {
tmp = get_attribute(soapOperation->properties, "soapAction"); tmp = get_attribute(soapOperation->properties, "soapAction");
if (tmp) { if (tmp) {
soapFunctionBinding->soapAction = strdup(tmp->children->content); soapFunctionBinding->soapAction = sdl_strdup(tmp->children->content);
} }
tmp = get_attribute(soapOperation->properties, "style"); tmp = get_attribute(soapOperation->properties, "style");
@ -639,9 +639,9 @@ static sdlPtr load_wsdl(char *struri)
name = get_attribute(input->properties, "name"); name = get_attribute(input->properties, "name");
if (name != NULL) { if (name != NULL) {
function->requestName = strdup(name->children->content); function->requestName = sdl_strdup(name->children->content);
} else { } else {
function->requestName = strdup(function->functionName); function->requestName = sdl_strdup(function->functionName);
} }
if (tmpbinding->bindingType == BINDING_SOAP) { if (tmpbinding->bindingType == BINDING_SOAP) {
@ -665,11 +665,11 @@ static sdlPtr load_wsdl(char *struri)
name = get_attribute(output->properties, "name"); name = get_attribute(output->properties, "name");
if (name != NULL) { if (name != NULL) {
function->responseName = strdup(name->children->content); function->responseName = sdl_strdup(name->children->content);
} else if (input == NULL) { } else if (input == NULL) {
function->responseName = strdup(function->functionName); function->responseName = sdl_strdup(function->functionName);
} else { } else {
function->responseName = malloc(strlen(function->functionName) + sizeof("Response")); function->responseName = sdl_malloc(strlen(function->functionName) + sizeof("Response"));
sprintf(function->responseName, "%sResponse", function->functionName); sprintf(function->responseName, "%sResponse", function->functionName);
} }
@ -702,8 +702,8 @@ static sdlPtr load_wsdl(char *struri)
efree(tmp); efree(tmp);
if (function->requestName != NULL && strcmp(function->requestName,function->functionName) != 0) { if (function->requestName != NULL && strcmp(function->requestName,function->functionName) != 0) {
if (ctx.sdl->requests == NULL) { if (ctx.sdl->requests == NULL) {
ctx.sdl->requests = malloc(sizeof(HashTable)); ctx.sdl->requests = sdl_malloc(sizeof(HashTable));
zend_hash_init(ctx.sdl->requests, 0, NULL, NULL, 1); zend_hash_init(ctx.sdl->requests, 0, NULL, NULL, SDL_PERSISTENT);
} }
tmp = estrdup(function->requestName); tmp = estrdup(function->requestName);
len = strlen(tmp); len = strlen(tmp);
@ -715,8 +715,8 @@ static sdlPtr load_wsdl(char *struri)
ENDFOREACH(trav2); ENDFOREACH(trav2);
if (!ctx.sdl->bindings) { if (!ctx.sdl->bindings) {
ctx.sdl->bindings = malloc(sizeof(HashTable)); ctx.sdl->bindings = sdl_malloc(sizeof(HashTable));
zend_hash_init(ctx.sdl->bindings, 0, NULL, delete_binding, 1); zend_hash_init(ctx.sdl->bindings, 0, NULL, delete_binding, SDL_PERSISTENT);
} }
zend_hash_add(ctx.sdl->bindings, tmpbinding->name, strlen(tmpbinding->name), &tmpbinding, sizeof(sdlBindingPtr), NULL); zend_hash_add(ctx.sdl->bindings, tmpbinding->name, strlen(tmpbinding->name), &tmpbinding, sizeof(sdlBindingPtr), NULL);
@ -740,6 +740,7 @@ static sdlPtr load_wsdl(char *struri)
sdlPtr get_sdl(char *uri) sdlPtr get_sdl(char *uri)
{ {
#ifdef SDL_CACHE
sdlPtr tmp, *hndl; sdlPtr tmp, *hndl;
TSRMLS_FETCH(); TSRMLS_FETCH();
@ -753,45 +754,53 @@ sdlPtr get_sdl(char *uri)
} }
return tmp; return tmp;
#else
return load_wsdl(uri);
#endif
} }
/* Deletes */ /* Deletes */
void delete_sdl(void *handle) void delete_sdl(void *handle)
{ {
sdlPtr tmp = *((sdlPtr*)handle); sdlPtr tmp = (sdlPtr)handle;
zend_hash_destroy(&tmp->functions); zend_hash_destroy(&tmp->functions);
if (tmp->source) { if (tmp->source) {
free(tmp->source); sdl_free(tmp->source);
} }
if (tmp->target_ns) { if (tmp->target_ns) {
free(tmp->target_ns); sdl_free(tmp->target_ns);
} }
if (tmp->elements) { if (tmp->elements) {
zend_hash_destroy(tmp->elements); zend_hash_destroy(tmp->elements);
free(tmp->elements); sdl_free(tmp->elements);
} }
if (tmp->encoders) { if (tmp->encoders) {
zend_hash_destroy(tmp->encoders); zend_hash_destroy(tmp->encoders);
free(tmp->encoders); sdl_free(tmp->encoders);
} }
if (tmp->types) { if (tmp->types) {
zend_hash_destroy(tmp->types); zend_hash_destroy(tmp->types);
free(tmp->types); sdl_free(tmp->types);
} }
if (tmp->groups) { if (tmp->groups) {
zend_hash_destroy(tmp->groups); zend_hash_destroy(tmp->groups);
free(tmp->groups); sdl_free(tmp->groups);
} }
if (tmp->bindings) { if (tmp->bindings) {
zend_hash_destroy(tmp->bindings); zend_hash_destroy(tmp->bindings);
free(tmp->bindings); sdl_free(tmp->bindings);
} }
if (tmp->requests) { if (tmp->requests) {
zend_hash_destroy(tmp->requests); zend_hash_destroy(tmp->requests);
free(tmp->requests); sdl_free(tmp->requests);
} }
free(tmp); sdl_free(tmp);
}
void delete_sdl_ptr(void *handle)
{
delete_sdl((sdlPtr*)handle);
} }
static void delete_binding(void *data) static void delete_binding(void *data)
@ -799,31 +808,36 @@ static void delete_binding(void *data)
sdlBindingPtr binding = *((sdlBindingPtr*)data); sdlBindingPtr binding = *((sdlBindingPtr*)data);
if (binding->location) { if (binding->location) {
free(binding->location); sdl_free(binding->location);
} }
if (binding->name) { if (binding->name) {
free(binding->name); sdl_free(binding->name);
} }
if (binding->bindingType == BINDING_SOAP) { if (binding->bindingType == BINDING_SOAP) {
sdlSoapBindingPtr soapBind = binding->bindingAttributes; sdlSoapBindingPtr soapBind = binding->bindingAttributes;
if (soapBind && soapBind->transport) { if (soapBind && soapBind->transport) {
free(soapBind->transport); sdl_free(soapBind->transport);
} }
sdl_free(soapBind);
} }
free(binding); sdl_free(binding);
} }
static void delete_sdl_soap_binding_function_body(sdlSoapBindingFunctionBody body) static void delete_sdl_soap_binding_function_body(sdlSoapBindingFunctionBody body)
{ {
if (body.ns) { if (body.ns) {
free(body.ns); sdl_free(body.ns);
} }
if (body.parts) { if (body.parts) {
free(body.parts); sdl_free(body.parts);
} }
if (body.encodingStyle) { if (body.encodingStyle) {
free(body.encodingStyle); sdl_free(body.encodingStyle);
}
if (body.headers) {
zend_hash_destroy(body.headers);
sdl_free(body.headers);
} }
} }
@ -832,58 +846,59 @@ static void delete_function(void *data)
sdlFunctionPtr function = *((sdlFunctionPtr*)data); sdlFunctionPtr function = *((sdlFunctionPtr*)data);
if (function->functionName) { if (function->functionName) {
free(function->functionName); sdl_free(function->functionName);
} }
if (function->requestName) { if (function->requestName) {
free(function->requestName); sdl_free(function->requestName);
} }
if (function->responseName) { if (function->responseName) {
free(function->responseName); sdl_free(function->responseName);
} }
if (function->requestParameters) { if (function->requestParameters) {
zend_hash_destroy(function->requestParameters); zend_hash_destroy(function->requestParameters);
free(function->requestParameters); sdl_free(function->requestParameters);
} }
if (function->responseParameters) { if (function->responseParameters) {
zend_hash_destroy(function->responseParameters); zend_hash_destroy(function->responseParameters);
free(function->responseParameters); sdl_free(function->responseParameters);
} }
if (function->bindingAttributes && if (function->bindingAttributes &&
function->binding && function->binding->bindingType == BINDING_SOAP) { function->binding && function->binding->bindingType == BINDING_SOAP) {
sdlSoapBindingFunctionPtr soapFunction = function->bindingAttributes; sdlSoapBindingFunctionPtr soapFunction = function->bindingAttributes;
if (soapFunction->soapAction) { if (soapFunction->soapAction) {
free(soapFunction->soapAction); sdl_free(soapFunction->soapAction);
} }
delete_sdl_soap_binding_function_body(soapFunction->input); delete_sdl_soap_binding_function_body(soapFunction->input);
delete_sdl_soap_binding_function_body(soapFunction->output); delete_sdl_soap_binding_function_body(soapFunction->output);
delete_sdl_soap_binding_function_body(soapFunction->falut); delete_sdl_soap_binding_function_body(soapFunction->falut);
sdl_free(soapFunction);
} }
free(function); sdl_free(function);
} }
static void delete_paramater(void *data) static void delete_paramater(void *data)
{ {
sdlParamPtr param = *((sdlParamPtr*)data); sdlParamPtr param = *((sdlParamPtr*)data);
if (param->paramName) { if (param->paramName) {
free(param->paramName); sdl_free(param->paramName);
} }
free(param); sdl_free(param);
} }
static void delete_header(void *data) static void delete_header(void *data)
{ {
sdlSoapBindingFunctionHeaderPtr hdr = *((sdlSoapBindingFunctionHeaderPtr*)data); sdlSoapBindingFunctionHeaderPtr hdr = *((sdlSoapBindingFunctionHeaderPtr*)data);
if (hdr->name) { if (hdr->name) {
free(hdr->name); sdl_free(hdr->name);
} }
if (hdr->ns) { if (hdr->ns) {
free(hdr->ns); sdl_free(hdr->ns);
} }
if (hdr->encodingStyle) { if (hdr->encodingStyle) {
free(hdr->encodingStyle); sdl_free(hdr->encodingStyle);
} }
free(hdr); sdl_free(hdr);
} }
static void delete_document(void *doc_ptr) static void delete_document(void *doc_ptr)

View file

@ -22,6 +22,18 @@
#ifndef PHP_SDL_H #ifndef PHP_SDL_H
#define PHP_SDL_H #define PHP_SDL_H
#ifdef SDL_CACHE
# define SDL_PERSISTENT 1
# define sdl_malloc malloc
# define sdl_strdup strdup
# define sdl_free free
#else
# define SDL_PERSISTENT 0
# define sdl_malloc emalloc
# define sdl_strdup estrdup
# define sdl_free efree
#endif
#define XSD_WHITESPACE_COLLAPSE 1 #define XSD_WHITESPACE_COLLAPSE 1
#define XSD_WHITESPACE_PRESERVE 1 #define XSD_WHITESPACE_PRESERVE 1
#define XSD_WHITESPACE_REPLACE 1 #define XSD_WHITESPACE_REPLACE 1
@ -229,5 +241,6 @@ sdlBindingPtr get_binding_from_type(sdlPtr sdl, int type);
sdlBindingPtr get_binding_from_name(sdlPtr sdl, char *name, char *ns); sdlBindingPtr get_binding_from_name(sdlPtr sdl, char *name, char *ns);
void delete_sdl(void *handle); void delete_sdl(void *handle);
void delete_sdl_ptr(void *handle);
#endif #endif

View file

@ -283,7 +283,7 @@ static void php_soap_init_globals(zend_soap_globals *soap_globals)
long enc; long enc;
soap_globals->sdls = malloc(sizeof(HashTable)); soap_globals->sdls = malloc(sizeof(HashTable));
zend_hash_init(soap_globals->sdls, 0, NULL, delete_sdl, 1); zend_hash_init(soap_globals->sdls, 0, NULL, delete_sdl_ptr, 1);
zend_hash_init(&soap_globals->defEnc, 0, NULL, NULL, 1); zend_hash_init(&soap_globals->defEnc, 0, NULL, NULL, 1);
zend_hash_init(&soap_globals->defEncIndex, 0, NULL, NULL, 1); zend_hash_init(&soap_globals->defEncIndex, 0, NULL, NULL, 1);
@ -395,8 +395,11 @@ PHP_MINIT_FUNCTION(soap)
INIT_CLASS_ENTRY(ce, PHP_SOAP_HEADER_CLASSNAME, soap_header_functions); INIT_CLASS_ENTRY(ce, PHP_SOAP_HEADER_CLASSNAME, soap_header_functions);
soap_header_class_entry = zend_register_internal_class(&ce TSRMLS_CC); soap_header_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
#ifdef SDL_CACHE
le_sdl = register_list_destructors(NULL, NULL); le_sdl = register_list_destructors(NULL, NULL);
#else
le_sdl = register_list_destructors(delete_sdl, NULL);
#endif
le_url = register_list_destructors(delete_url, NULL); le_url = register_list_destructors(delete_url, NULL);
le_service = register_list_destructors(delete_service, NULL); le_service = register_list_destructors(delete_service, NULL);
@ -739,7 +742,7 @@ PHP_FUNCTION(SoapServer,map)
FETCH_THIS_SERVICE(service); FETCH_THIS_SERVICE(service);
new_enc = malloc(sizeof(encode)); new_enc = emalloc(sizeof(encode));
memset(new_enc, 0, sizeof(encode)); memset(new_enc, 0, sizeof(encode));
ctype = strrchr(type, ':'); ctype = strrchr(type, ':');
@ -769,8 +772,8 @@ PHP_FUNCTION(SoapServer,map)
} }
new_enc->details.type = enc->details.type; new_enc->details.type = enc->details.type;
new_enc->details.ns = strdup(enc->details.ns); new_enc->details.ns = estrdup(enc->details.ns);
new_enc->details.type_str = strdup(enc->details.type_str); new_enc->details.type_str = estrdup(enc->details.type_str);
new_enc->details.sdl_type = enc->details.sdl_type; new_enc->details.sdl_type = enc->details.sdl_type;
new_enc->to_xml = enc->to_xml; new_enc->to_xml = enc->to_xml;
new_enc->to_zval = enc->to_zval; new_enc->to_zval = enc->to_zval;
@ -818,7 +821,7 @@ PHP_FUNCTION(SoapServer,map)
if (!service->mapping) { if (!service->mapping) {
service->mapping = emalloc(sizeof(HashTable)); service->mapping = emalloc(sizeof(HashTable));
zend_hash_init(service->mapping, 0, NULL, delete_encoder, 0); zend_hash_init(service->mapping, 0, NULL, delete_tmp_encoder, 0);
} }
zend_hash_update(service->mapping, type, type_len + 1, &new_enc, sizeof(encodePtr), NULL); zend_hash_update(service->mapping, type, type_len + 1, &new_enc, sizeof(encodePtr), NULL);
smart_str_free(&resloved_ns); smart_str_free(&resloved_ns);
@ -3092,5 +3095,10 @@ static void delete_service(void *data)
if (service->uri) { if (service->uri) {
efree(service->uri); efree(service->uri);
} }
#ifndef SDL_CACHE
if (service->sdl) {
delete_sdl(service->sdl);
}
#endif
efree(service); efree(service);
} }