From 0425aadc78680e53000fd0108b540d6eca048516 Mon Sep 17 00:00:00 2001 From: gmcdonald Date: Sat, 13 Feb 2010 01:32:03 +0000 Subject: Moving axis svn, part of TLP move INFRA-2441 git-svn-id: http://svn.apache.org/repos/asf/axis/axis2/c/core/trunk@909681 13f79535-47bb-0310-9956-ffa450edef68 --- guththila/src/guththila_namespace.c | 139 ++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 guththila/src/guththila_namespace.c (limited to 'guththila/src/guththila_namespace.c') diff --git a/guththila/src/guththila_namespace.c b/guththila/src/guththila_namespace.c new file mode 100644 index 0000000..7cd9a50 --- /dev/null +++ b/guththila/src/guththila_namespace.c @@ -0,0 +1,139 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 +#include +#include +#include +#include + +int GUTHTHILA_CALL +guththila_namespace_list_grow( + guththila_namespace_list_t * namesp_list, + int addition, + const axutil_env_t * env) +{ + int i = 0; + if(addition > 0 || (addition < 0 && namesp_list->capacity + addition > 0 + && namesp_list->capacity + addition >= namesp_list->size)) + { + namesp_list->list = (guththila_namespace_t *)realloc(namesp_list->list, + sizeof(guththila_namespace_t) * (namesp_list->capacity + addition)); + if(namesp_list->list) + { + for(i = namesp_list->capacity; i < namesp_list->capacity + addition; i++) + { + guththila_stack_push(&namesp_list->fr_stack, namesp_list->list + i, env); + } + namesp_list->capacity += addition; + } + else + { + return GUTHTHILA_FAILURE; + } + } + return 0; +} + +guththila_namespace_list_t *GUTHTHILA_CALL +guththila_namespace_list_create( + const axutil_env_t * env) +{ + int i = 0; + guththila_namespace_list_t * namesp_list = (guththila_namespace_list_t *)AXIS2_MALLOC( + env->allocator, sizeof(guththila_namespace_list_t)); + + if(!namesp_list) + return NULL; + + namesp_list->list = (guththila_namespace_t *)AXIS2_MALLOC(env->allocator, + sizeof(guththila_namespace_t) * GUTHTHILA_NAMESPACE_DEF_SIZE); + + if(namesp_list->list && guththila_stack_init(&namesp_list->fr_stack, env)) + { + namesp_list->capacity = GUTHTHILA_NAMESPACE_DEF_SIZE; + namesp_list->size = 0; + for(i = 0; i < GUTHTHILA_NAMESPACE_DEF_SIZE; i++) + { + guththila_stack_push(&namesp_list->fr_stack, namesp_list->list + i, env); + } + return namesp_list; + } + return NULL; +} + +int GUTHTHILA_CALL +guththila_namespace_list_init( + guththila_namespace_list_t * namesp_list, + const axutil_env_t * env) +{ + int i = 0; + namesp_list->list = (guththila_namespace_t *)AXIS2_MALLOC(env->allocator, + sizeof(guththila_namespace_t) * GUTHTHILA_NAMESPACE_DEF_SIZE); + if(namesp_list->list && guththila_stack_init(&namesp_list->fr_stack, env)) + { + namesp_list->capacity = GUTHTHILA_NAMESPACE_DEF_SIZE; + namesp_list->size = 0; + for(i = 0; i < GUTHTHILA_NAMESPACE_DEF_SIZE; i++) + { + guththila_stack_push(&namesp_list->fr_stack, namesp_list->list + i, env); + } + return GUTHTHILA_SUCCESS; + } + return GUTHTHILA_FAILURE; +} + +guththila_namespace_t *GUTHTHILA_CALL +guththila_namespace_list_get( + guththila_namespace_list_t *namesp_list, + const axutil_env_t * env) +{ + if(namesp_list->fr_stack.top > 0 || guththila_namespace_list_grow(namesp_list, + GUTHTHILA_NAMESPACE_DEF_SIZE, env)) + { + return guththila_stack_pop(&namesp_list->fr_stack, env); + } + return NULL; +} + +int GUTHTHILA_CALL +guththila_namespace_list_release( + guththila_namespace_list_t * namesp_list, + guththila_namespace_t * namespace, + const axutil_env_t * env) +{ + return guththila_stack_push(&namesp_list->fr_stack, namespace, env); +} + +void GUTHTHILA_CALL +msuila_namespace_list_free_data( + guththila_namespace_list_t * namesp_list, + const axutil_env_t * env) +{ + AXIS2_FREE(env->allocator, namesp_list->list); + guththila_stack_un_init(&namesp_list->fr_stack, env); +} + +void GUTHTHILA_CALL +guththila_namespace_list_free( + guththila_namespace_list_t * namesp_list, + const axutil_env_t * env) +{ + + guththila_stack_un_init(&namesp_list->fr_stack, env); + AXIS2_FREE(env->allocator, namesp_list->list); + AXIS2_FREE(env->allocator, namesp_list); +} -- cgit v1.1-32-gdbae