axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dami...@apache.org
Subject svn commit: r379682 - in /webservices/axis2/trunk/c/modules/util: axis2_property.h property.c
Date Wed, 22 Feb 2006 04:58:37 GMT
Author: damitha
Date: Tue Feb 21 20:58:35 2006
New Revision: 379682

URL: http://svn.apache.org/viewcvs?rev=379682&view=rev
Log:
property struct is meant as a solution to release memory
occupied by properties. For every property set in wsdl_component_properties
we need to wrap it inside this struct. When we wrap the property
by this struct we also set the scope of property and free function
of property

Added:
    webservices/axis2/trunk/c/modules/util/axis2_property.h
    webservices/axis2/trunk/c/modules/util/property.c

Added: webservices/axis2/trunk/c/modules/util/axis2_property.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/axis2_property.h?rev=379682&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/util/axis2_property.h (added)
+++ webservices/axis2/trunk/c/modules/util/axis2_property.h Tue Feb 21 20:58:35 2006
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef AXIS2_PROPERTY_H
+#define AXIS2_PROPERTY_H
+
+#include <axis2_defines.h>
+#include <axis2_error.h>
+#include <axis2_env.h>
+#include <axis2.h>
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+    
+typedef struct axis2_property axis2_property_t;
+typedef struct axis2_property_ops axis2_property_ops_t;
+    
+/**
+ * @defgroup axis2_property Property
+ * @ingroup axis2_util 
+ * @{
+ */
+
+/** 
+ * @brief Description Builder ops struct
+ * Encapsulator struct for ops of axis2_desc_builder
+ */
+AXIS2_DECLARE_DATA struct axis2_property_ops
+{
+
+    axis2_status_t (AXIS2_CALL *
+    free) (axis2_property_t *property, 
+            axis2_env_t **env);
+
+    axis2_status_t (AXIS2_CALL *
+    set_scope) (axis2_property_t *property,
+                axis2_env_t **env,
+                axis2_scope_t scope);
+
+    axis2_status_t (AXIS2_CALL *
+    set_free_func) (axis2_property_t *property,
+                    axis2_env_t **env,
+                    AXIS2_FREE_VOID_ARG free_func);
+
+    axis2_status_t (AXIS2_CALL *
+    set_value) (axis2_property_t *property,
+                axis2_env_t **env,
+                void *value);
+
+};
+    
+     
+/** 
+     * @brief
+     */ 
+AXIS2_DECLARE_DATA struct axis2_property
+{
+	axis2_property_ops_t *ops;
+};
+
+/**
+ * create new property
+ * @return property newly created property
+ */
+AXIS2_DECLARE(axis2_property_t *)
+axis2_property_create(axis2_env_t **env);
+
+/*************************** Function macros **********************************/
+
+#define AXIS2_PROPERTY_FREE(property, env) \
+		((property)->ops->free (property, env))
+
+#define AXIS2_PROPERTY_SET_FREE_FUNC(property, env, free_func) \
+		((property)->ops->set_free_func (property, env, free_func))  
+
+#define AXIS2_PROPERTY_SET_SCOPE(property, env, scope) \
+		((property)->ops->set_scope (property, env, scope)) 
+
+#define AXIS2_PROPERTY_SET_VALUE(property, env, value) \
+		((property)->ops->set_value (property, env, value))
+
+
+                                        
+/*************************** End of function macros ***************************/
+
+
+
+/** @} */
+    
+#ifdef __cplusplus
+}
+#endif
+
+#endif  /* AXIS2_PROPERTY_H */

Added: webservices/axis2/trunk/c/modules/util/property.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/property.c?rev=379682&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/util/property.c (added)
+++ webservices/axis2/trunk/c/modules/util/property.c Tue Feb 21 20:58:35 2006
@@ -0,0 +1,168 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+#include <axis2_property.h>
+
+typedef struct axis2_property_impl
+{
+    axis2_property_t property;
+    axis2_scope_t scope;
+    AXIS2_FREE_VOID_ARG free_func;
+    void *value;
+    
+}axis2_property_impl_t;
+
+#define AXIS2_INTF_TO_IMPL(property) \
+    ((axis2_property_impl_t *) property)
+
+axis2_status_t AXIS2_CALL
+axis2_property_free (axis2_property_t *property, 
+                    axis2_env_t **env); 
+
+axis2_status_t AXIS2_CALL
+axis2_property_set_scope(axis2_property_t *property,
+                            axis2_env_t **env,
+                            axis2_scope_t scope);
+
+axis2_status_t AXIS2_CALL
+axis2_property_set_free_func(axis2_property_t *property,
+                            axis2_env_t **env,
+                            AXIS2_FREE_VOID_ARG free_func);
+
+axis2_status_t AXIS2_CALL
+axis2_property_set_value(axis2_property_t *property,
+                            axis2_env_t **env,
+                            void *value);
+
+/************************** End of function prototypes ************************/
+
+axis2_property_t *AXIS2_CALL 
+axis2_property_create(axis2_env_t **env)
+{
+    axis2_property_impl_t *property_impl = NULL;
+    
+	AXIS2_ENV_CHECK(env, NULL);
+	
+	property_impl = (axis2_property_impl_t *) AXIS2_MALLOC((*env)->allocator, 
+        sizeof(axis2_property_impl_t));
+	
+	if(NULL == property_impl)
+    {
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); 
+        return NULL;
+    }
+    property_impl->value= NULL;
+    property_impl->scope = AXIS2_SCOPE_APPLICATION;
+    property_impl->free_func = 0;
+    
+    property_impl->property.ops = 
+		AXIS2_MALLOC ((*env)->allocator, sizeof(axis2_property_ops_t));
+	if(NULL == property_impl->property.ops)
+    {
+        axis2_property_free(&(property_impl->property), env);
+		AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+    }
+    
+    property_impl->property.ops->free =  axis2_property_free;
+    property_impl->property.ops->set_free_func = axis2_property_set_free_func;
+    property_impl->property.ops->set_scope = axis2_property_set_scope;
+    property_impl->property.ops->set_value = axis2_property_set_value;
+	
+	return &(property_impl->property);
+}
+
+/***************************Function implementation****************************/
+
+axis2_status_t AXIS2_CALL 
+axis2_property_free (axis2_property_t *property, 
+                    axis2_env_t **env)
+{
+    axis2_property_impl_t *property_impl = NULL;
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    property_impl = AXIS2_INTF_TO_IMPL(property);
+    
+    if(property_impl->value)
+    {
+        if(property_impl->scope != AXIS2_SCOPE_REQUEST)
+        {
+            if(property_impl->free_func)
+            {
+                property_impl->free_func(property_impl->value, env);
+            }
+            else
+            {
+                AXIS2_FREE((*env)->allocator, property_impl->value);
+            }
+            property_impl->value = NULL;
+        }
+    }
+    
+    if(property_impl->property.ops)
+    {
+        AXIS2_FREE((*env)->allocator, property_impl->property.ops);
+        property_impl->property.ops = NULL;
+    }
+    
+    if(property_impl)
+    {
+        AXIS2_FREE((*env)->allocator, property_impl);
+        property_impl = NULL;
+    }
+    return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_property_set_scope(axis2_property_t *property,
+                            axis2_env_t **env,
+                            axis2_scope_t scope)
+{
+    axis2_property_impl_t *property_impl = NULL;
+
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    property_impl = AXIS2_INTF_TO_IMPL(property);
+   
+    property_impl->scope = scope;
+    return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_property_set_free_func(axis2_property_t *property,
+                            axis2_env_t **env,
+                            AXIS2_FREE_VOID_ARG free_func)
+{
+    axis2_property_impl_t *property_impl = NULL;
+
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    property_impl = AXIS2_INTF_TO_IMPL(property);
+   
+    property_impl->free_func = free_func;
+    return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_property_set_value(axis2_property_t *property,
+                            axis2_env_t **env,
+                            void *value)
+{
+    axis2_property_impl_t *property_impl = NULL;
+
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    property_impl = AXIS2_INTF_TO_IMPL(property);
+   
+    property_impl->value = value;
+    return AXIS2_SUCCESS;
+}



Mime
View raw message