]> granicus.if.org Git - php/commitdiff
WSDL cache was disabled by default (see WSDL_CACHE macro)
authorDmitry Stogov <dmitry@php.net>
Fri, 6 Feb 2004 14:22:33 +0000 (14:22 +0000)
committerDmitry Stogov <dmitry@php.net>
Fri, 6 Feb 2004 14:22:33 +0000 (14:22 +0000)
WSDL related memory leaks were fixed

ext/soap/php_encoding.c
ext/soap/php_encoding.h
ext/soap/php_schema.c
ext/soap/php_sdl.c
ext/soap/php_sdl.h
ext/soap/soap.c

index 3a7f3a243c70a5fba87935a31db2474f0f9b48a9..69768b67d5d314486ee4a4c79684cb99ccece2ea 100644 (file)
@@ -2600,13 +2600,28 @@ void delete_encoder(void *encode)
 {
        encodePtr t = *((encodePtr*)encode);
        if (t->details.ns) {
-               free(t->details.ns);
+               sdl_free(t->details.ns);
        }
        if (t->details.type_str) {
-               free(t->details.type_str);
+               sdl_free(t->details.type_str);
        }
        if (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);
 }
index 47069d102031c4e089e6b4ac5b863762c5c88cc2..f00ea77bc954973d0648c8c575d54f317cd7c90d 100644 (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);
 
 void delete_encoder(void *handle);
+void delete_tmp_encoder(void *encode);
 
 extern encode defaultEncoding[];
 
index 5fe7037249ed8621ca77f9f880ea99a3cf25de83..dbe229733d301113095f7dfc1440c857cb54f192 100644 (file)
@@ -59,8 +59,8 @@ static encodePtr create_encoder(sdlPtr sdl, sdlTypePtr cur_type, const char *ns,
        encodePtr enc, *enc_ptr;
 
        if (sdl->encoders == NULL) {
-               sdl->encoders = malloc(sizeof(HashTable));
-               zend_hash_init(sdl->encoders, 0, NULL, delete_encoder, 1);
+               sdl->encoders = sdl_malloc(sizeof(HashTable));
+               zend_hash_init(sdl->encoders, 0, NULL, delete_encoder, SDL_PERSISTENT);
        }
        smart_str_appends(&nscat, ns);
        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) {
                enc = *enc_ptr;
                if (enc->details.ns) {
-                       free(enc->details.ns);
+                       sdl_free(enc->details.ns);
                }
                if (enc->details.type_str) {
-                       free(enc->details.type_str);
+                       sdl_free(enc->details.type_str);
                }
        } else {
                enc_ptr = NULL;
-               enc = malloc(sizeof(encode));
+               enc = sdl_malloc(sizeof(encode));
        }
        memset(enc, 0, sizeof(encode));
 
-       enc->details.ns = strdup(ns);
-       enc->details.type_str = strdup(type);
+       enc->details.ns = sdl_strdup(ns);
+       enc->details.type_str = sdl_strdup(type);
        enc->details.sdl_type = cur_type;
        enc->to_xml = sdl_guess_convert_xml;
        enc->to_zval = sdl_guess_convert_zval;
@@ -185,8 +185,8 @@ int load_schema(sdlCtx *ctx,xmlNodePtr schema)
        xmlAttrPtr tns;
 
        if (!ctx->sdl->types) {
-               ctx->sdl->types = malloc(sizeof(HashTable));
-               zend_hash_init(ctx->sdl->types, 0, NULL, delete_type, 1);
+               ctx->sdl->types = sdl_malloc(sizeof(HashTable));
+               zend_hash_init(ctx->sdl->types, 0, NULL, delete_type, SDL_PERSISTENT);
        }
        if (!ctx->attributes) {
                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> */
                sdlTypePtr newType, *ptr;
 
-               newType = malloc(sizeof(sdlType));
+               newType = sdl_malloc(sizeof(sdlType));
                memset(newType, 0, sizeof(sdlType));
                newType->kind = XSD_TYPEKIND_SIMPLE;
                if (name != NULL) {
-                       newType->name = strdup(name->children->content);
-                       newType->namens = strdup(ns->children->content);
+                       newType->name = sdl_strdup(name->children->content);
+                       newType->namens = sdl_strdup(ns->children->content);
                } else {
-                       newType->name = strdup(cur_type->name);
-                       newType->namens = strdup(cur_type->namens);
+                       newType->name = sdl_strdup(cur_type->name);
+                       newType->namens = sdl_strdup(cur_type->namens);
                }
 
                zend_hash_next_index_insert(sdl->types,  &newType, sizeof(sdlTypePtr), (void **)&ptr);
 
                if (sdl->encoders == NULL) {
-                       sdl->encoders = malloc(sizeof(HashTable));
-                       zend_hash_init(sdl->encoders, 0, NULL, delete_encoder, 1);
+                       sdl->encoders = sdl_malloc(sizeof(HashTable));
+                       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));
-               cur_type->encode->details.ns = strdup(newType->namens);
-               cur_type->encode->details.type_str = strdup(newType->name);
+               cur_type->encode->details.ns = sdl_strdup(newType->namens);
+               cur_type->encode->details.type_str = sdl_strdup(newType->name);
                cur_type->encode->details.sdl_type = *ptr;
                cur_type->encode->to_xml = sdl_guess_convert_xml;
                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) {
                sdlTypePtr newType, *ptr;
 
-               newType = malloc(sizeof(sdlType));
+               newType = sdl_malloc(sizeof(sdlType));
                memset(newType, 0, sizeof(sdlType));
                newType->kind = XSD_TYPEKIND_SIMPLE;
-               newType->name = strdup(name->children->content);
-               newType->namens = strdup(ns->children->content);
+               newType->name = sdl_strdup(name->children->content);
+               newType->namens = sdl_strdup(ns->children->content);
 
                if (cur_type == NULL) {
                        zend_hash_next_index_insert(sdl->types,  &newType, sizeof(sdlTypePtr), (void **)&ptr);
                } else {
                        if (cur_type->elements == NULL) {
-                               cur_type->elements = malloc(sizeof(HashTable));
-                               zend_hash_init(cur_type->elements, 0, NULL, delete_type, 1);
+                               cur_type->elements = sdl_malloc(sizeof(HashTable));
+                               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);
                }
@@ -434,17 +434,17 @@ static int schema_list(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr listType, sdlTypeP
                if (nsptr != NULL) {
                        sdlTypePtr newType, *tmp;
 
-                       newType = malloc(sizeof(sdlType));
+                       newType = sdl_malloc(sizeof(sdlType));
                        memset(newType, 0, sizeof(sdlType));
 
-                       newType->name = strdup(type);
-                       newType->namens = strdup(nsptr->href);
+                       newType->name = sdl_strdup(type);
+                       newType->namens = sdl_strdup(nsptr->href);
 
                        newType->encode = get_create_encoder(sdl, newType, (char *)nsptr->href, type);
 
                        if (cur_type->elements == NULL) {
-                               cur_type->elements = malloc(sizeof(HashTable));
-                               zend_hash_init(cur_type->elements, 0, NULL, delete_type, 1);
+                               cur_type->elements = sdl_malloc(sizeof(HashTable));
+                               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);
                }
@@ -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");
                }
 
-               newType = malloc(sizeof(sdlType));
+               newType = sdl_malloc(sizeof(sdlType));
                memset(newType, 0, sizeof(sdlType));
 
-               newType->name = strdup("anonymous");
-               newType->namens = strdup(tsn->children->content);
+               newType->name = sdl_strdup("anonymous");
+               newType->namens = sdl_strdup(tsn->children->content);
 
                if (cur_type->elements == NULL) {
-                       cur_type->elements = malloc(sizeof(HashTable));
-                       zend_hash_init(cur_type->elements, 0, NULL, delete_type, 1);
+                       cur_type->elements = sdl_malloc(sizeof(HashTable));
+                       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);
 
@@ -521,17 +521,17 @@ static int schema_union(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr unionType, sdlTyp
                        if (nsptr != NULL) {
                                sdlTypePtr newType, *tmp;
 
-                               newType = malloc(sizeof(sdlType));
+                               newType = sdl_malloc(sizeof(sdlType));
                                memset(newType, 0, sizeof(sdlType));
 
-                               newType->name = strdup(type);
-                               newType->namens = strdup(nsptr->href);
+                               newType->name = sdl_strdup(type);
+                               newType->namens = sdl_strdup(nsptr->href);
 
                                newType->encode = get_create_encoder(sdl, newType, (char *)nsptr->href, type);
 
                                if (cur_type->elements == NULL) {
-                                       cur_type->elements = malloc(sizeof(HashTable));
-                                       zend_hash_init(cur_type->elements, 0, NULL, delete_type, 1);
+                                       cur_type->elements = sdl_malloc(sizeof(HashTable));
+                                       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);
                        }
@@ -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");
                        }
 
-                       newType = malloc(sizeof(sdlType));
+                       newType = sdl_malloc(sizeof(sdlType));
                        memset(newType, 0, sizeof(sdlType));
 
-                       newType->name = strdup("anonymous");
-                       newType->namens = strdup(tsn->children->content);
+                       newType->name = sdl_strdup("anonymous");
+                       newType->namens = sdl_strdup(tsn->children->content);
 
                        if (cur_type->elements == NULL) {
-                               cur_type->elements = malloc(sizeof(HashTable));
-                               zend_hash_init(cur_type->elements, 0, NULL, delete_type, 1);
+                               cur_type->elements = sdl_malloc(sizeof(HashTable));
+                               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);
 
@@ -655,7 +655,7 @@ static int schema_restriction_simpleContent(sdlPtr sdl, xmlAttrPtr tsn, xmlNodeP
        }
 
        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));
        }
 
@@ -696,8 +696,8 @@ static int schema_restriction_simpleContent(sdlPtr sdl, xmlAttrPtr tsn, xmlNodeP
 
                        schema_restriction_var_char(trav, &enumval);
                        if (cur_type->restrictions->enumeration == NULL) {
-                               cur_type->restrictions->enumeration = malloc(sizeof(HashTable));
-                               zend_hash_init(cur_type->restrictions->enumeration, 0, NULL, delete_schema_restriction_var_char, 1);
+                               cur_type->restrictions->enumeration = sdl_malloc(sizeof(HashTable));
+                               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);
                } else {
@@ -803,7 +803,7 @@ static int schema_restriction_var_int(xmlNodePtr val, sdlRestrictionIntPtr *valp
        xmlAttrPtr fixed, value;
 
        if ((*valptr) == NULL) {
-               (*valptr) = malloc(sizeof(sdlRestrictionInt));
+               (*valptr) = sdl_malloc(sizeof(sdlRestrictionInt));
        }
        memset((*valptr), 0, sizeof(sdlRestrictionInt));
 
@@ -830,7 +830,7 @@ static int schema_restriction_var_char(xmlNodePtr val, sdlRestrictionCharPtr *va
        xmlAttrPtr fixed, value;
 
        if ((*valptr) == NULL) {
-               (*valptr) = malloc(sizeof(sdlRestrictionChar));
+               (*valptr) = sdl_malloc(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");
        }
 
-       (*valptr)->value = strdup(value->children->content);
+       (*valptr)->value = sdl_strdup(value->children->content);
        return TRUE;
 }
 
@@ -992,10 +992,10 @@ static int schema_all(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr all, sdlTypePtr cur
        xmlAttrPtr attr;
        sdlContentModelPtr newModel;
 
-       newModel = malloc(sizeof(sdlContentModel));
+       newModel = sdl_malloc(sizeof(sdlContentModel));
        newModel->kind = XSD_CONTENT_ALL;
-       newModel->u.content = malloc(sizeof(HashTable));
-       zend_hash_init(newModel->u.content, 0, NULL, delete_model, 1);
+       newModel->u.content = sdl_malloc(sizeof(HashTable));
+       zend_hash_init(newModel->u.content, 0, NULL, delete_model, SDL_PERSISTENT);
        if (model == NULL) {
                cur_type->model = newModel;
        } else {
@@ -1079,17 +1079,17 @@ static int schema_group(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr groupType, sdlTyp
                        smart_str_appends(&key, type);
                        smart_str_0(&key);
 
-                       newModel = malloc(sizeof(sdlContentModel));
+                       newModel = sdl_malloc(sizeof(sdlContentModel));
                        newModel->kind = XSD_CONTENT_GROUP_REF;
                        newModel->u.group_ref = estrdup(key.c);
 
                        if (type) {efree(type);}
                        if (ns) {efree(ns);}
                } else {
-                       newModel = malloc(sizeof(sdlContentModel));
+                       newModel = sdl_malloc(sizeof(sdlContentModel));
                        newModel->kind = XSD_CONTENT_SEQUENCE; /* will be redefined */
-                       newModel->u.content = malloc(sizeof(HashTable));
-                       zend_hash_init(newModel->u.content, 0, NULL, delete_model, 1);
+                       newModel->u.content = sdl_malloc(sizeof(HashTable));
+                       zend_hash_init(newModel->u.content, 0, NULL, delete_model, SDL_PERSISTENT);
 
                        smart_str_appends(&key, ns->children->content);
                        smart_str_appendc(&key, ':');
@@ -1100,12 +1100,12 @@ static int schema_group(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr groupType, sdlTyp
                if (cur_type == NULL) {
                        sdlTypePtr newType;
 
-                       newType = malloc(sizeof(sdlType));
+                       newType = sdl_malloc(sizeof(sdlType));
                        memset(newType, 0, sizeof(sdlType));
 
                        if (sdl->groups == NULL) {
-                               sdl->groups = malloc(sizeof(HashTable));
-                               zend_hash_init(sdl->groups, 0, NULL, delete_type, 1);
+                               sdl->groups = sdl_malloc(sizeof(HashTable));
+                               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) {
                                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;
        sdlContentModelPtr newModel;
 
-       newModel = malloc(sizeof(sdlContentModel));
+       newModel = sdl_malloc(sizeof(sdlContentModel));
        newModel->kind = XSD_CONTENT_CHOICE;
-       newModel->u.content = malloc(sizeof(HashTable));
-       zend_hash_init(newModel->u.content, 0, NULL, delete_model, 1);
+       newModel->u.content = sdl_malloc(sizeof(HashTable));
+       zend_hash_init(newModel->u.content, 0, NULL, delete_model, SDL_PERSISTENT);
        if (model == NULL) {
                cur_type->model = newModel;
        } else {
@@ -1258,10 +1258,10 @@ static int schema_sequence(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr seqType, sdlTy
        xmlAttrPtr attr;
        sdlContentModelPtr newModel;
 
-       newModel = malloc(sizeof(sdlContentModel));
+       newModel = sdl_malloc(sizeof(sdlContentModel));
        newModel->kind = XSD_CONTENT_SEQUENCE;
-       newModel->u.content = malloc(sizeof(HashTable));
-       zend_hash_init(newModel->u.content, 0, NULL, delete_model, 1);
+       newModel->u.content = sdl_malloc(sizeof(HashTable));
+       zend_hash_init(newModel->u.content, 0, NULL, delete_model, SDL_PERSISTENT);
        if (model == NULL) {
                cur_type->model = newModel;
        } else {
@@ -1383,27 +1383,27 @@ static int schema_complexType(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr compType, s
                /* Anonymous type inside <element> */
                sdlTypePtr newType, *ptr;
 
-               newType = malloc(sizeof(sdlType));
+               newType = sdl_malloc(sizeof(sdlType));
                memset(newType, 0, sizeof(sdlType));
                newType->kind = XSD_TYPEKIND_COMPLEX;
                if (name != NULL) {
-                       newType->name = strdup(name->children->content);
-                       newType->namens = strdup(ns->children->content);
+                       newType->name = sdl_strdup(name->children->content);
+                       newType->namens = sdl_strdup(ns->children->content);
                } else {
-                       newType->name = strdup(cur_type->name);
-                       newType->namens = strdup(cur_type->namens);
+                       newType->name = sdl_strdup(cur_type->name);
+                       newType->namens = sdl_strdup(cur_type->namens);
                }
 
                zend_hash_next_index_insert(sdl->types,  &newType, sizeof(sdlTypePtr), (void **)&ptr);
 
                if (sdl->encoders == NULL) {
-                       sdl->encoders = malloc(sizeof(HashTable));
-                       zend_hash_init(sdl->encoders, 0, NULL, delete_encoder, 1);
+                       sdl->encoders = sdl_malloc(sizeof(HashTable));
+                       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));
-               cur_type->encode->details.ns = strdup(newType->namens);
-               cur_type->encode->details.type_str = strdup(newType->name);
+               cur_type->encode->details.ns = sdl_strdup(newType->namens);
+               cur_type->encode->details.type_str = sdl_strdup(newType->name);
                cur_type->encode->details.sdl_type = *ptr;
                cur_type->encode->to_xml = sdl_guess_convert_xml;
                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) {
                sdlTypePtr newType, *ptr;
 
-               newType = malloc(sizeof(sdlType));
+               newType = sdl_malloc(sizeof(sdlType));
                memset(newType, 0, sizeof(sdlType));
                newType->kind = XSD_TYPEKIND_COMPLEX;
-               newType->name = strdup(name->children->content);
-               newType->namens = strdup(ns->children->content);
+               newType->name = sdl_strdup(name->children->content);
+               newType->namens = sdl_strdup(ns->children->content);
 
                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;
                smart_str key = {0};
 
-               newType = malloc(sizeof(sdlType));
+               newType = sdl_malloc(sizeof(sdlType));
                memset(newType, 0, sizeof(sdlType));
 
                if (ref) {
@@ -1530,26 +1530,26 @@ static int schema_element(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr element, sdlTyp
                        if (nsptr != NULL) {
                                smart_str_appends(&nscat, nsptr->href);
                                smart_str_appendc(&nscat, ':');
-                               newType->namens = strdup(nsptr->href);
+                               newType->namens = sdl_strdup(nsptr->href);
                        }
                        smart_str_appends(&nscat, type);
-                       newType->name = strdup(type);
+                       newType->name = sdl_strdup(type);
                        smart_str_0(&nscat);
                        if (type) {efree(type);}
                        if (ns) {efree(ns);}
                        newType->ref = estrdup(nscat.c);
                        smart_str_free(&nscat);
                } else {
-                       newType->name = strdup(name->children->content);
-                       newType->namens = strdup(ns->children->content);
+                       newType->name = sdl_strdup(name->children->content);
+                       newType->namens = sdl_strdup(ns->children->content);
                }
 
                newType->nillable = FALSE;
 
                if (cur_type == NULL) {
                        if (sdl->elements == NULL) {
-                               sdl->elements = malloc(sizeof(HashTable));
-                               zend_hash_init(sdl->elements, 0, NULL, delete_type, 1);
+                               sdl->elements = sdl_malloc(sizeof(HashTable));
+                               zend_hash_init(sdl->elements, 0, NULL, delete_type, SDL_PERSISTENT);
                        }
                        addHash = sdl->elements;
                        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);
                } else {
                        if (cur_type->elements == NULL) {
-                               cur_type->elements = malloc(sizeof(HashTable));
-                               zend_hash_init(cur_type->elements, 0, NULL, delete_type, 1);
+                               cur_type->elements = sdl_malloc(sizeof(HashTable));
+                               zend_hash_init(cur_type->elements, 0, NULL, delete_type, SDL_PERSISTENT);
                        }
                        addHash = cur_type->elements;
                        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);
 
                if (model != NULL) {
-                       sdlContentModelPtr newModel = malloc(sizeof(sdlContentModel));
+                       sdlContentModelPtr newModel = sdl_malloc(sizeof(sdlContentModel));
 
                        newModel->kind = XSD_CONTENT_ELEMENT;
                        newModel->u.element = newType;
@@ -1625,7 +1625,7 @@ static int schema_element(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr element, sdlTyp
                if (ref != NULL) {
                        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");
@@ -1635,7 +1635,7 @@ static int schema_element(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr element, sdlTyp
                } else if (ref != NULL) {
                        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 */
@@ -1724,7 +1724,7 @@ static int schema_attribute(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr attrType, sdl
                HashTable *addHash;
                smart_str key = {0};
 
-               newAttr = malloc(sizeof(sdlAttribute));
+               newAttr = sdl_malloc(sizeof(sdlAttribute));
                memset(newAttr, 0, sizeof(sdlAttribute));
 
                if (ref) {
@@ -1761,8 +1761,8 @@ static int schema_attribute(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr attrType, sdl
                        addHash = ctx->attributes;
                } else {
                        if (cur_type->attributes == NULL) {
-                               cur_type->attributes = malloc(sizeof(HashTable));
-                               zend_hash_init(cur_type->attributes, 0, NULL, delete_attribute, 1);
+                               cur_type->attributes = sdl_malloc(sizeof(HashTable));
+                               zend_hash_init(cur_type->attributes, 0, NULL, delete_attribute, SDL_PERSISTENT);
                        }
                        addHash = cur_type->attributes;
                }
@@ -1796,9 +1796,9 @@ static int schema_attribute(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr attrType, sdl
        attr = attrType->properties;
        while (attr != NULL) {
                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)) {
-                       newAttr->fixed = strdup(attr->children->content);
+                       newAttr->fixed = sdl_strdup(attr->children->content);
                } else if (attr_is_equal_ex(attr, "form", SCHEMA_NAMESPACE)) {
                        if (strncmp(attr->children->content,"qualified",sizeof("qualified")) == 0) {
                          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)) {
                        /* skip */
                } 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)) {
                        /* already processed */
                } 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;
                                char *value, *ns;
 
-                               ext = malloc(sizeof(sdlExtraAttribute));
+                               ext = sdl_malloc(sizeof(sdlExtraAttribute));
                                memset(ext, 0, sizeof(sdlExtraAttribute));
                                parse_namespace(attr->children->content, &value, &ns);
                                nsptr = xmlSearchNs(attr->doc, attr->parent, ns);
                                if (nsptr) {
-                                       ext->ns = strdup(nsptr->href);
-                                       ext->val = strdup(value);
+                                       ext->ns = sdl_strdup(nsptr->href);
+                                       ext->val = sdl_strdup(value);
                                } else {
-                                       ext->val = strdup(attr->children->content);
+                                       ext->val = sdl_strdup(attr->children->content);
                                }
                                if (ns) {efree(ns);}
                                efree(value);
 
                                if (!newAttr->extraAttributes) {
-                                       newAttr->extraAttributes = malloc(sizeof(HashTable));
-                                       zend_hash_init(newAttr->extraAttributes, 0, NULL, delete_extra_attribute, 1);
+                                       newAttr->extraAttributes = sdl_malloc(sizeof(HashTable));
+                                       zend_hash_init(newAttr->extraAttributes, 0, NULL, delete_extra_attribute, SDL_PERSISTENT);
                                }
 
                                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) {
                                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));
-                       dummy_type->name = strdup("anonymous");
-                       dummy_type->namens = strdup(tsn->children->content);
+                       dummy_type->name = sdl_strdup("anonymous");
+                       dummy_type->namens = sdl_strdup(tsn->children->content);
                        schema_simpleType(sdl, tsn, trav, dummy_type);
                        newAttr->encode = dummy_type->encode;
                        delete_type(&dummy_type);
@@ -1912,10 +1912,10 @@ static int schema_attributeGroup(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr attrGrou
                        if (ns == NULL) {
                                ns = tsn;
                        }
-                       newType = malloc(sizeof(sdlType));
+                       newType = sdl_malloc(sizeof(sdlType));
                        memset(newType, 0, sizeof(sdlType));
-                       newType->name = strdup(name->children->content);
-                       newType->namens = strdup(ns->children->content);
+                       newType->name = sdl_strdup(name->children->content);
+                       newType->namens = sdl_strdup(ns->children->content);
 
                        smart_str_appends(&key, newType->namens);
                        smart_str_appendc(&key, ':');
@@ -1934,10 +1934,10 @@ static int schema_attributeGroup(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr attrGrou
                        xmlNsPtr nsptr;
 
                        if (cur_type->attributes == NULL) {
-                               cur_type->attributes = malloc(sizeof(HashTable));
-                               zend_hash_init(cur_type->attributes, 0, NULL, delete_attribute, 1);
+                               cur_type->attributes = sdl_malloc(sizeof(HashTable));
+                               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));
 
                        parse_namespace(ref->children->content, &group_name, &ns);
@@ -1995,14 +1995,14 @@ static void copy_extra_attribute(void *attribute)
        sdlExtraAttributePtr *attr = (sdlExtraAttributePtr*)attribute;
        sdlExtraAttributePtr new_attr;
 
-       new_attr = malloc(sizeof(sdlExtraAttribute));
+       new_attr = sdl_malloc(sizeof(sdlExtraAttribute));
        memcpy(new_attr, *attr, sizeof(sdlExtraAttribute));
        *attr = new_attr;
        if (new_attr->ns) {
-               new_attr->ns = strdup(new_attr->ns);
+               new_attr->ns = sdl_strdup(new_attr->ns);
        }
        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) {
                                schema_attribute_fixup(ctx, *tmp);
                                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) {
-                                       attr->def = strdup((*tmp)->def);
+                                       attr->def = sdl_strdup((*tmp)->def);
                                }
                                if ((*tmp)->fixed != NULL && attr->fixed == NULL) {
-                                       attr->fixed = strdup((*tmp)->fixed);
+                                       attr->fixed = sdl_strdup((*tmp)->fixed);
                                }
                                if (attr->form == XSD_FORM_DEFAULT) {
                                        attr->form = (*tmp)->form;
@@ -2032,8 +2032,8 @@ static void schema_attribute_fixup(sdlCtx *ctx, sdlAttributePtr attr)
                                if ((*tmp)->extraAttributes != NULL) {
                                  xmlNodePtr node;
 
-                                       attr->extraAttributes = malloc(sizeof(HashTable));
-                                       zend_hash_init(attr->extraAttributes, 0, NULL, delete_extra_attribute, 1);
+                                       attr->extraAttributes = sdl_malloc(sizeof(HashTable));
+                                       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));
                                }
                                attr->encode = (*tmp)->encode;
@@ -2042,7 +2042,7 @@ static void schema_attribute_fixup(sdlCtx *ctx, sdlAttributePtr attr)
                if (attr->name == NULL && attr->ref != NULL) {
                        char *name, *ns;
                        parse_namespace(attr->ref, &name, &ns);
-                       attr->name = strdup(name);
+                       attr->name = sdl_strdup(name);
                        if (name) {efree(name);}
                        if (ns) {efree(ns);}
                }
@@ -2069,15 +2069,15 @@ static void schema_attributegroup_fixup(sdlCtx *ctx, sdlAttributePtr attr, HashT
 
                                                        schema_attribute_fixup(ctx,*tmp_attr);
 
-                                                       newAttr = malloc(sizeof(sdlAttribute));
+                                                       newAttr = sdl_malloc(sizeof(sdlAttribute));
                                                        memcpy(newAttr, *tmp_attr, sizeof(sdlAttribute));
-                                                       if (newAttr->def) {newAttr->def = strdup(newAttr->def);}
-                                                       if (newAttr->fixed) {newAttr->fixed = strdup(newAttr->fixed);}
-                                                       if (newAttr->name) {newAttr->name = strdup(newAttr->name);}
+                                                       if (newAttr->def) {newAttr->def = sdl_strdup(newAttr->def);}
+                                                       if (newAttr->fixed) {newAttr->fixed = sdl_strdup(newAttr->fixed);}
+                                                       if (newAttr->name) {newAttr->name = sdl_strdup(newAttr->name);}
                                                        if (newAttr->extraAttributes) {
                                                          xmlNodePtr node;
-                                                               HashTable *ht = malloc(sizeof(HashTable));
-                                                               zend_hash_init(ht, 0, NULL, delete_extra_attribute, 1);
+                                                               HashTable *ht = sdl_malloc(sizeof(HashTable));
+                                                               zend_hash_init(ht, 0, NULL, delete_extra_attribute, SDL_PERSISTENT);
                                                                zend_hash_copy(ht, newAttr->extraAttributes, copy_extra_attribute, &node, sizeof(xmlNodePtr));
                                                                newAttr->extraAttributes = ht;
                                                        }
@@ -2241,37 +2241,40 @@ static void delete_model(void *handle)
                case XSD_CONTENT_ALL:
                case XSD_CONTENT_CHOICE:
                        zend_hash_destroy(tmp->u.content);
-                       free(tmp->u.content);
+                       sdl_free(tmp->u.content);
                        break;
                case XSD_CONTENT_GROUP_REF:
                        efree(tmp->u.group_ref);
                        break;
        }
-       free(tmp);
+       sdl_free(tmp);
 }
 
 static void delete_type(void *data)
 {
        sdlTypePtr type = *((sdlTypePtr*)data);
        if (type->name) {
-               free(type->name);
+               sdl_free(type->name);
        }
        if (type->namens) {
-               free(type->namens);
+               sdl_free(type->namens);
        }
        if (type->def) {
-               free(type->def);
+               sdl_free(type->def);
        }
        if (type->fixed) {
-               free(type->fixed);
+               sdl_free(type->fixed);
        }
        if (type->elements) {
                zend_hash_destroy(type->elements);
-               free(type->elements);
+               sdl_free(type->elements);
        }
        if (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) {
                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);
                if (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)
@@ -2299,12 +2302,12 @@ static void delete_extra_attribute(void *attribute)
        sdlExtraAttributePtr attr = *((sdlExtraAttributePtr*)attribute);
 
        if (attr->ns) {
-               free(attr->ns);
+               sdl_free(attr->ns);
        }
        if (attr->val) {
-               free(attr->val);
+               sdl_free(attr->val);
        }
-       free(attr);
+       sdl_free(attr);
 }
 
 static void delete_attribute(void *attribute)
@@ -2312,29 +2315,29 @@ static void delete_attribute(void *attribute)
        sdlAttributePtr attr = *((sdlAttributePtr*)attribute);
 
        if (attr->def) {
-               free(attr->def);
+               sdl_free(attr->def);
        }
        if (attr->fixed) {
-               free(attr->fixed);
+               sdl_free(attr->fixed);
        }
        if (attr->name) {
-               free(attr->name);
+               sdl_free(attr->name);
        }
        if (attr->ref) {
-               free(attr->ref);
+               sdl_free(attr->ref);
        }
        if (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)
 {
        sdlRestrictionIntPtr ptr = *((sdlRestrictionIntPtr*)rvi);
        if (ptr) {
-               free(ptr);
+               sdl_free(ptr);
        }
 }
 
@@ -2343,8 +2346,8 @@ static void delete_schema_restriction_var_char(void *srvc)
        sdlRestrictionCharPtr ptr = *((sdlRestrictionCharPtr*)srvc);
        if (ptr) {
                if (ptr->value) {
-                       free(ptr->value);
+                       sdl_free(ptr->value);
                }
-               free(ptr);
+               sdl_free(ptr);
        }
 }
index 3e8607adc3ae787fa83d7371f06256ee0e72a174..88785da83be23a836f477485252523692cb810fb 100644 (file)
@@ -175,7 +175,7 @@ static void load_wsdl_ex(char *struri, sdlCtx *ctx, int include)
        if (!include) {
                targetNamespace = get_attribute(definitions->properties, "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");
                if (tmp) {
-                       binding->ns = strdup(tmp->children->content);
+                       binding->ns = sdl_strdup(tmp->children->content);
                }
 
                tmp = get_attribute(body->properties, "parts");
                if (tmp) {
-                       binding->parts = strdup(tmp->children->content);
+                       binding->parts = sdl_strdup(tmp->children->content);
                }
 
                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) {
                                php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Unspecified encodingStyle");
                        } 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);
                }
 
-               h = malloc(sizeof(sdlSoapBindingFunctionHeader));
+               h = sdl_malloc(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");
                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");
                if (tmp) {
-                       h->ns = strdup(tmp->children->content);
+                       h->ns = sdl_strdup(tmp->children->content);
                }
 
                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) {
                                php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Unspecified encodingStyle");
                        } else {
-                               h->encodingStyle = strdup(tmp->children->content);
+                               h->encodingStyle = sdl_strdup(tmp->children->content);
                        }
                }
 
                if (binding->headers == NULL) {
-                       binding->headers = malloc(sizeof(HashTable));
-                       zend_hash_init(binding->headers, 0, NULL, delete_header, 1);
+                       binding->headers = sdl_malloc(sizeof(HashTable));
+                       zend_hash_init(binding->headers, 0, NULL, delete_header, SDL_PERSISTENT);
                }
 
                if (h->ns) {
@@ -395,15 +395,15 @@ static HashTable* wsdl_message(sdlCtx *ctx, char* message_name)
        if (ctype) {efree(ctype);}
        if (ns) {efree(ns);}
 
-       parameters = malloc(sizeof(HashTable));
-       zend_hash_init(parameters, 0, NULL, delete_paramater, 1);
+       parameters = sdl_malloc(sizeof(HashTable));
+       zend_hash_init(parameters, 0, NULL, delete_paramater, SDL_PERSISTENT);
 
        trav = message->children;
        FOREACHNODE(trav, "part", part) {
                xmlAttrPtr element, type, name;
                sdlParamPtr param;
 
-               param = malloc(sizeof(sdlParam));
+               param = sdl_malloc(sizeof(sdlParam));
                memset(param,0,sizeof(sdlParam));
                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);
                }
 
-               param->paramName = strdup(name->children->content);
+               param->paramName = sdl_strdup(name->children->content);
 
                type = get_attribute(part->properties, "type");
                if (type != NULL) {
@@ -439,10 +439,10 @@ static sdlPtr load_wsdl(char *struri)
        int i,n;
 
        memset(&ctx,0,sizeof(ctx));
-       ctx.sdl = malloc(sizeof(sdl));
+       ctx.sdl = sdl_malloc(sizeof(sdl));
        memset(ctx.sdl, 0, sizeof(sdl));
-       ctx.sdl->source = strdup(struri);
-       zend_hash_init(&ctx.sdl->functions, 0, NULL, delete_function, 1);
+       ctx.sdl->source = sdl_strdup(struri);
+       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.messages, 0, NULL, NULL, 0);
@@ -472,7 +472,7 @@ static sdlPtr load_wsdl(char *struri)
                                sdlBindingPtr tmpbinding;
                                char *wsdl_soap_namespace = NULL;
 
-                               tmpbinding = malloc(sizeof(sdlBinding));
+                               tmpbinding = sdl_malloc(sizeof(sdlBinding));
                                memset(tmpbinding, 0, sizeof(sdlBinding));
 
                                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>");
                                }
 
-                               tmpbinding->location = strdup(location->children->content);
+                               tmpbinding->location = sdl_strdup(location->children->content);
 
                                if (address->ns) {
                                        if (!strncmp(address->ns->href, WSDL_SOAP11_NAMESPACE, sizeof(WSDL_SOAP11_NAMESPACE))) {
@@ -528,7 +528,7 @@ static sdlPtr load_wsdl(char *struri)
                                        xmlNodePtr soapBindingNode;
                                        xmlAttrPtr tmp;
 
-                                       soapBinding = malloc(sizeof(sdlSoapBinding));
+                                       soapBinding = sdl_malloc(sizeof(sdlSoapBinding));
                                        memset(soapBinding, 0, sizeof(sdlSoapBinding));
                                        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))) {
                                                                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;
@@ -554,7 +554,7 @@ static sdlPtr load_wsdl(char *struri)
                                if (name == NULL) {
                                        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");
                                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);
                                        }
 
-                                       function = malloc(sizeof(sdlFunction));
-                                       function->functionName = strdup(op_name->children->content);
+                                       function = sdl_malloc(sizeof(sdlFunction));
+                                       function->functionName = sdl_strdup(op_name->children->content);
                                        function->requestParameters = NULL;
                                        function->responseParameters = NULL;
                                        function->responseName = NULL;
@@ -600,7 +600,7 @@ static sdlPtr load_wsdl(char *struri)
                                                xmlNodePtr soapOperation;
                                                xmlAttrPtr tmp;
 
-                                               soapFunctionBinding = malloc(sizeof(sdlSoapBindingFunction));
+                                               soapFunctionBinding = sdl_malloc(sizeof(sdlSoapBindingFunction));
                                                memset(soapFunctionBinding, 0, sizeof(sdlSoapBindingFunction));
                                                soapBinding = (sdlSoapBindingPtr)tmpbinding->bindingAttributes;
                                                soapFunctionBinding->style = soapBinding->style;
@@ -609,7 +609,7 @@ static sdlPtr load_wsdl(char *struri)
                                                if (soapOperation) {
                                                        tmp = get_attribute(soapOperation->properties, "soapAction");
                                                        if (tmp) {
-                                                               soapFunctionBinding->soapAction = strdup(tmp->children->content);
+                                                               soapFunctionBinding->soapAction = sdl_strdup(tmp->children->content);
                                                        }
 
                                                        tmp = get_attribute(soapOperation->properties, "style");
@@ -639,9 +639,9 @@ static sdlPtr load_wsdl(char *struri)
 
                                                name = get_attribute(input->properties, "name");
                                                if (name != NULL) {
-                                                       function->requestName = strdup(name->children->content);
+                                                       function->requestName = sdl_strdup(name->children->content);
                                                } else {
-                                                       function->requestName = strdup(function->functionName);
+                                                       function->requestName = sdl_strdup(function->functionName);
                                                }
 
                                                if (tmpbinding->bindingType == BINDING_SOAP) {
@@ -665,11 +665,11 @@ static sdlPtr load_wsdl(char *struri)
 
                                                name = get_attribute(output->properties, "name");
                                                if (name != NULL) {
-                                                       function->responseName = strdup(name->children->content);
+                                                       function->responseName = sdl_strdup(name->children->content);
                                                } else if (input == NULL) {
-                                                       function->responseName = strdup(function->functionName);
+                                                       function->responseName = sdl_strdup(function->functionName);
                                                } else {
-                                                       function->responseName = malloc(strlen(function->functionName) + sizeof("Response"));
+                                                       function->responseName = sdl_malloc(strlen(function->functionName) + sizeof("Response"));
                                                        sprintf(function->responseName, "%sResponse", function->functionName);
                                                }
 
@@ -702,8 +702,8 @@ static sdlPtr load_wsdl(char *struri)
                                                efree(tmp);
                                                if (function->requestName != NULL && strcmp(function->requestName,function->functionName) != 0) {
                                                        if (ctx.sdl->requests == NULL) {
-                                                               ctx.sdl->requests = malloc(sizeof(HashTable));
-                                                               zend_hash_init(ctx.sdl->requests, 0, NULL, NULL, 1);
+                                                               ctx.sdl->requests = sdl_malloc(sizeof(HashTable));
+                                                               zend_hash_init(ctx.sdl->requests, 0, NULL, NULL, SDL_PERSISTENT);
                                                        }
                                                        tmp = estrdup(function->requestName);
                                                        len = strlen(tmp);
@@ -715,8 +715,8 @@ static sdlPtr load_wsdl(char *struri)
                                ENDFOREACH(trav2);
 
                                if (!ctx.sdl->bindings) {
-                                       ctx.sdl->bindings = malloc(sizeof(HashTable));
-                                       zend_hash_init(ctx.sdl->bindings, 0, NULL, delete_binding, 1);
+                                       ctx.sdl->bindings = sdl_malloc(sizeof(HashTable));
+                                       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);
@@ -740,6 +740,7 @@ static sdlPtr load_wsdl(char *struri)
 
 sdlPtr get_sdl(char *uri)
 {
+#ifdef SDL_CACHE
        sdlPtr tmp, *hndl;
        TSRMLS_FETCH();
 
@@ -753,45 +754,53 @@ sdlPtr get_sdl(char *uri)
        }
 
        return tmp;
+#else
+       return load_wsdl(uri);
+#endif
 }
 
 /* Deletes */
 void delete_sdl(void *handle)
 {
-       sdlPtr tmp = *((sdlPtr*)handle);
+       sdlPtr tmp = (sdlPtr)handle;
 
        zend_hash_destroy(&tmp->functions);
        if (tmp->source) {
-               free(tmp->source);
+               sdl_free(tmp->source);
        }
        if (tmp->target_ns) {
-               free(tmp->target_ns);
+               sdl_free(tmp->target_ns);
        }
        if (tmp->elements) {
                zend_hash_destroy(tmp->elements);
-               free(tmp->elements);
+               sdl_free(tmp->elements);
        }
        if (tmp->encoders) {
                zend_hash_destroy(tmp->encoders);
-               free(tmp->encoders);
+               sdl_free(tmp->encoders);
        }
        if (tmp->types) {
                zend_hash_destroy(tmp->types);
-               free(tmp->types);
+               sdl_free(tmp->types);
        }
        if (tmp->groups) {
                zend_hash_destroy(tmp->groups);
-               free(tmp->groups);
+               sdl_free(tmp->groups);
        }
        if (tmp->bindings) {
                zend_hash_destroy(tmp->bindings);
-               free(tmp->bindings);
+               sdl_free(tmp->bindings);
        }
        if (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)
@@ -799,31 +808,36 @@ static void delete_binding(void *data)
        sdlBindingPtr binding = *((sdlBindingPtr*)data);
 
        if (binding->location) {
-               free(binding->location);
+               sdl_free(binding->location);
        }
        if (binding->name) {
-               free(binding->name);
+               sdl_free(binding->name);
        }
 
        if (binding->bindingType == BINDING_SOAP) {
                sdlSoapBindingPtr soapBind = binding->bindingAttributes;
                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)
 {
        if (body.ns) {
-               free(body.ns);
+               sdl_free(body.ns);
        }
        if (body.parts) {
-               free(body.parts);
+               sdl_free(body.parts);
        }
        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);
 
        if (function->functionName) {
-               free(function->functionName);
+               sdl_free(function->functionName);
        }
        if (function->requestName) {
-               free(function->requestName);
+               sdl_free(function->requestName);
        }
        if (function->responseName) {
-               free(function->responseName);
+               sdl_free(function->responseName);
        }
        if (function->requestParameters) {
                zend_hash_destroy(function->requestParameters);
-               free(function->requestParameters);
+               sdl_free(function->requestParameters);
        }
        if (function->responseParameters) {
                zend_hash_destroy(function->responseParameters);
-               free(function->responseParameters);
+               sdl_free(function->responseParameters);
        }
 
        if (function->bindingAttributes &&
            function->binding && function->binding->bindingType == BINDING_SOAP) {
                sdlSoapBindingFunctionPtr soapFunction = function->bindingAttributes;
                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->output);
                delete_sdl_soap_binding_function_body(soapFunction->falut);
+               sdl_free(soapFunction);
        }
-       free(function);
+       sdl_free(function);
 }
 
 static void delete_paramater(void *data)
 {
        sdlParamPtr param = *((sdlParamPtr*)data);
        if (param->paramName) {
-               free(param->paramName);
+               sdl_free(param->paramName);
        }
-       free(param);
+       sdl_free(param);
 }
 
 static void delete_header(void *data)
 {
        sdlSoapBindingFunctionHeaderPtr hdr = *((sdlSoapBindingFunctionHeaderPtr*)data);
        if (hdr->name) {
-               free(hdr->name);
+               sdl_free(hdr->name);
        }
        if (hdr->ns) {
-               free(hdr->ns);
+               sdl_free(hdr->ns);
        }
        if (hdr->encodingStyle) {
-               free(hdr->encodingStyle);
+               sdl_free(hdr->encodingStyle);
        }
-       free(hdr);
+       sdl_free(hdr);
 }
 
 static void delete_document(void *doc_ptr)
index 4b53b2b295b511405b76513bab0d7d10cb9adb87..2886f1200efc88ed13764e506f1b6ba74624eab3 100644 (file)
 #ifndef 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_PRESERVE 1
-#define XSD_WHITESPACE_REPLACE 1
+#define XSD_WHITESPACE_REPLACE  1
 
 #define BINDING_SOAP 1
 #define BINDING_HTTP 2
@@ -229,5 +241,6 @@ sdlBindingPtr get_binding_from_type(sdlPtr sdl, int type);
 sdlBindingPtr get_binding_from_name(sdlPtr sdl, char *name, char *ns);
 
 void delete_sdl(void *handle);
+void delete_sdl_ptr(void *handle);
 
 #endif
index 4ee1de533759e416bb2dcf1ccd17108510b1b936..b57d2df9a2334de3a6ac4cc302d5e92907663fa0 100644 (file)
@@ -283,7 +283,7 @@ static void php_soap_init_globals(zend_soap_globals *soap_globals)
        long enc;
 
        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->defEncIndex, 0, NULL, NULL, 1);
@@ -395,8 +395,11 @@ PHP_MINIT_FUNCTION(soap)
 
        INIT_CLASS_ENTRY(ce, PHP_SOAP_HEADER_CLASSNAME, soap_header_functions);
        soap_header_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
-
+#ifdef SDL_CACHE
        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_service = register_list_destructors(delete_service, NULL);
 
@@ -739,7 +742,7 @@ PHP_FUNCTION(SoapServer,map)
 
                FETCH_THIS_SERVICE(service);
 
-               new_enc = malloc(sizeof(encode));
+               new_enc = emalloc(sizeof(encode));
                memset(new_enc, 0, sizeof(encode));
 
                ctype = strrchr(type, ':');
@@ -769,8 +772,8 @@ PHP_FUNCTION(SoapServer,map)
                }
 
                new_enc->details.type = enc->details.type;
-               new_enc->details.ns = strdup(enc->details.ns);
-               new_enc->details.type_str = strdup(enc->details.type_str);
+               new_enc->details.ns = estrdup(enc->details.ns);
+               new_enc->details.type_str = estrdup(enc->details.type_str);
                new_enc->details.sdl_type = enc->details.sdl_type;
                new_enc->to_xml = enc->to_xml;
                new_enc->to_zval = enc->to_zval;
@@ -818,7 +821,7 @@ PHP_FUNCTION(SoapServer,map)
 
                if (!service->mapping) {
                        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);
                smart_str_free(&resloved_ns);
@@ -3092,5 +3095,10 @@ static void delete_service(void *data)
        if (service->uri) {
                efree(service->uri);
        }
+#ifndef SDL_CACHE
+       if (service->sdl) {
+               delete_sdl(service->sdl);
+       }
+#endif
        efree(service);
 }