You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2007/01/26 05:00:07 UTC
svn commit: r500137 - in /webservices/axis2/trunk/c/guththila:
include/guththila.h include/guththila_buffer.h samples/guththila_main.c
src/guththila_buffer.c src/guththila_writer.c src/guththila_xml_pull_parser.c
Author: dinesh
Date: Thu Jan 25 20:00:06 2007
New Revision: 500137
URL: http://svn.apache.org/viewvc?view=rev&rev=500137
Log:
guththila reader memory lead fixed, buffer growing problem fixed
Modified:
webservices/axis2/trunk/c/guththila/include/guththila.h
webservices/axis2/trunk/c/guththila/include/guththila_buffer.h
webservices/axis2/trunk/c/guththila/samples/guththila_main.c
webservices/axis2/trunk/c/guththila/src/guththila_buffer.c
webservices/axis2/trunk/c/guththila/src/guththila_writer.c
webservices/axis2/trunk/c/guththila/src/guththila_xml_pull_parser.c
Modified: webservices/axis2/trunk/c/guththila/include/guththila.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/include/guththila.h?view=diff&rev=500137&r1=500136&r2=500137
==============================================================================
--- webservices/axis2/trunk/c/guththila/include/guththila.h (original)
+++ webservices/axis2/trunk/c/guththila/include/guththila.h Thu Jan 25 20:00:06 2007
@@ -61,11 +61,11 @@
GUTHTHILA_START_DOCUMENT = 0,
GUTHTHILA_START_ELEMENT,
GUTHTHILA_END_ELEMENT,
- GUTHTHILA_SPACE,
- GUTHTHILA_EMPTY_ELEMENT,
+ GUTHTHILA_EMPTY_ELEMENT,
GUTHTHILA_CHARACTER,
GUTHTHILA_ENTITY_REFERANCE,
- GUTHTHILA_COMMENT
+ GUTHTHILA_COMMENT,
+ GUTHTHILA_SPACE,
};
@@ -82,7 +82,8 @@
axis2_stack_t *stack;
axis2_stack_t *attrib;
axis2_stack_t *namesp;
- axis2_stack_t *dep;
+ axis2_stack_t *dep;
+ axis2_stack_t *other;
int _next;
int offset;
int last;
Modified: webservices/axis2/trunk/c/guththila/include/guththila_buffer.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/include/guththila_buffer.h?view=diff&rev=500137&r1=500136&r2=500137
==============================================================================
--- webservices/axis2/trunk/c/guththila/include/guththila_buffer.h (original)
+++ webservices/axis2/trunk/c/guththila/include/guththila_buffer.h Thu Jan 25 20:00:06 2007
@@ -35,7 +35,7 @@
guththila_char_t *buff;
} guththila_buffer_t;
-#define GUTHTHILA_BUFFER_SIZE 2000
+#define GUTHTHILA_BUFFER_SIZE 50
AXIS2_EXTERN guththila_buffer_t * AXIS2_CALL
guththila_buffer_create (axis2_env_t * environment, int size);
@@ -49,6 +49,7 @@
AXIS2_EXTERN guththila_buffer_t *
guththila_buffer_grow (axis2_env_t * environment,
- guththila_buffer_t * name);
+ guththila_buffer_t * name,
+ int buffer_length);
#endif /* GUTHTHILA_BUFFER_H */
Modified: webservices/axis2/trunk/c/guththila/samples/guththila_main.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/samples/guththila_main.c?view=diff&rev=500137&r1=500136&r2=500137
==============================================================================
--- webservices/axis2/trunk/c/guththila/samples/guththila_main.c (original)
+++ webservices/axis2/trunk/c/guththila/samples/guththila_main.c Thu Jan 25 20:00:06 2007
@@ -28,7 +28,7 @@
guththila_t *parser;
char *xml_buffer;
allocator = axis2_allocator_init(NULL);
- xml_buffer = "<?xml version = \"1.0\"?><test a=\"din\">123</test>";
+ xml_buffer = "<?xml version = \"1.0\"?><test a=\"din\">addddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd123</test>";
environment =
axis2_env_create(allocator);
@@ -131,18 +131,25 @@
{
p = guththila_get_namespace_prefix_by_number(environment, parser, d);
if (strncmp(p, "xmlns", 5))
+ {
printf(" xmlns:");
- printf("%s=\"", p);
+ printf("%s=\"", p);
+ }
+ else
+ printf (" xmlns=\"");
AXIS2_FREE(allocator, p);
p = guththila_get_namespace_uri_by_number
(environment, parser, d);
- printf("%s\" ", p);
+ printf("%s\"", p);
AXIS2_FREE(allocator, p);
}
if (parser->guththila_event == GUTHTHILA_START_ELEMENT)
printf(">");
- else
+ else if (parser->guththila_event == GUTHTHILA_EMPTY_ELEMENT)
printf("/>");
+ else
+ printf ("error \n");
+
}
break;
case GUTHTHILA_END_ELEMENT:
Modified: webservices/axis2/trunk/c/guththila/src/guththila_buffer.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_buffer.c?view=diff&rev=500137&r1=500136&r2=500137
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_buffer.c (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_buffer.c Thu Jan 25 20:00:06 2007
@@ -40,8 +40,8 @@
if (size)
{
name->buff = (guththila_char_t *) AXIS2_MALLOC(
- environment->allocator, size * sizeof (guththila_char_t));
- memset (name->buff, 0, size);
+ environment->allocator, (size+1) * sizeof (guththila_char_t));
+ name->buff [size] = 0;
}
}
return name;
@@ -87,13 +87,22 @@
AXIS2_EXTERN guththila_buffer_t *
guththila_buffer_grow(axis2_env_t * environment,
- guththila_buffer_t * name)
+ guththila_buffer_t * name,
+ int buffer_length)
{
guththila_char_t *x = NULL;
+
name->size <<= 1;
+
+ if (buffer_length > name->size)
+ {
+ name->size += buffer_length;
+ }
+
x = (guththila_char_t *) AXIS2_MALLOC(environment->allocator, name->size + 1);
- memset (x, 0, name->size);
+ x[name->size] = 0;
+
if (x)
{
memcpy (x, name->buff, strlen (name->buff));
Modified: webservices/axis2/trunk/c/guththila/src/guththila_writer.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_writer.c?view=diff&rev=500137&r1=500136&r2=500137
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_writer.c (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_writer.c Thu Jan 25 20:00:06 2007
@@ -93,11 +93,15 @@
if ((size + length) > writer_impl->buffer->size)
{
- writer_impl->buffer = guththila_buffer_grow(env, writer_impl->buffer);
+ writer_impl->buffer = guththila_buffer_grow(env, writer_impl->buffer, length);
}
- memcpy (writer_impl->buffer->buff, buffer, strlen (buffer));
- writer_impl->buffer->next += length;
- c = length;
+
+ if (buffer)
+ {
+ memcpy (writer_impl->buffer->buff + size, buffer, strlen (buffer));
+ writer_impl->buffer->next += length;
+ c = length;
+ }
}
return c;
}
Modified: webservices/axis2/trunk/c/guththila/src/guththila_xml_pull_parser.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_xml_pull_parser.c?view=diff&rev=500137&r1=500136&r2=500137
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_xml_pull_parser.c (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_xml_pull_parser.c Thu Jan 25 20:00:06 2007
@@ -46,6 +46,7 @@
parser->attrib = axis2_stack_create(environment);
parser->namesp = axis2_stack_create(environment);
parser->dep = axis2_stack_create(environment);
+ parser->other = axis2_stack_create (environment);
parser->name = NULL;
parser->prefix = NULL;
parser->value = NULL;
@@ -67,14 +68,24 @@
guththila_free(axis2_env_t * environment,
guththila_t * parser)
{
+ int ii = 0;
if (parser->buffer)
guththila_buffer_free(environment, (void *) parser->buffer);
if (parser->name)
guththila_token_free (environment, parser->name);
+
if (parser->stack)
{
+ ii = AXIS2_STACK_SIZE(parser->stack, environment);
+ for (; ii > 0; ii--)
+ {
+ guththila_token_t *d;
+ d = (guththila_token_t *)AXIS2_STACK_POP(parser->stack, environment);
+ guththila_token_free (environment, d);
+ }
+
AXIS2_STACK_FREE(parser->stack, environment);
}
@@ -91,7 +102,28 @@
}
if (parser->namesp)
- AXIS2_STACK_FREE(parser->namesp, environment);
+ {
+ int ii = AXIS2_STACK_SIZE(parser->namesp, environment);
+ guththila_namespace_t *namespace;
+
+ for (; ii > 0; ii--)
+ {
+ namespace = (guththila_namespace_t *) AXIS2_STACK_POP(parser->namesp, environment);
+ if (namespace->name)
+ {
+ AXIS2_FREE(environment->allocator, namespace->name);
+ namespace->name = NULL;
+ }
+ if (namespace->uri)
+ {
+ AXIS2_FREE(environment->allocator, namespace->uri);
+ namespace->uri = NULL;
+ }
+ AXIS2_FREE (environment->allocator, namespace);
+ }
+ AXIS2_STACK_FREE(parser->namesp, environment);
+ }
+
if (parser->dep)
{
int ii = AXIS2_STACK_SIZE(parser->dep, environment);
@@ -104,6 +136,19 @@
AXIS2_STACK_FREE(parser->dep, environment);
}
+ if (parser->other)
+ {
+ int ii = AXIS2_STACK_SIZE(parser->other, environment);
+ void *element = NULL;
+ for (; ii > 0; ii--)
+ {
+ element = AXIS2_STACK_POP(parser->other, environment);
+ AXIS2_FREE(environment->allocator, element);
+ }
+ AXIS2_STACK_FREE(parser->other, environment);
+ }
+
+
AXIS2_FREE(environment->allocator, (void *) parser);
}
@@ -164,11 +209,14 @@
else
{
int b = 0;
+ guththila_char_t *buff;
+ buff = parser->buffer->buff;
b = parser->buffer->size;
parser->buffer =
- guththila_buffer_grow(environment, parser->buffer);
- guththila_relocate_tokens(
- environment, parser, (parser->buffer->size - b));
+ guththila_buffer_grow(environment, parser->buffer, parser->_next);
+ guththila_relocate_tokens(environment, parser,
+ (buff - parser->buffer->buff));
+ AXIS2_STACK_PUSH(parser->other, environment, buff);
}
}
c = guththila_reader_read(environment, (parser->buffer->buff),
@@ -558,9 +606,9 @@
ii = AXIS2_STACK_SIZE(parser->stack, environment);
for (; ii > 0; ii--)
{
- void *d;
- d = AXIS2_STACK_POP(parser->stack, environment);
- AXIS2_FREE(environment->allocator, d);
+ guththila_token_t *d;
+ d = (guththila_token_t *)AXIS2_STACK_POP(parser->stack, environment);
+ guththila_token_free (environment, d);
}
if (parser->guththila_event == GUTHTHILA_END_ELEMENT
@@ -998,13 +1046,18 @@
if (!guththila_token_compare
(environment, token, "xmlns", 5,
parser->unicode_state))
+ {
guththila_add_namespace(environment,
parser, name,
value);
+ guththila_token_free (environment, name);
+ guththila_token_free (environment, value);
+ }
else
guththila_add_attribute(environment,
parser, name,
value);
+
}
else if (token->type == _name)
{
@@ -1027,6 +1080,7 @@
name,
attribute->
value);
+ guththila_attribute_free (environment, attribute);
}
else
{
@@ -1134,6 +1188,7 @@
AXIS2_FREE(environment->allocator, namespace->uri);
namespace->uri = NULL;
}
+ AXIS2_FREE (environment->allocator, namespace);
}
if (depth)
AXIS2_FREE (environment->allocator, depth);
@@ -1187,8 +1242,6 @@
uri,
parser->unicode_state);
ns->lengthuri = AXIS2_STRLEN(ns->uri);
- guththila_token_free (environment, name);
- guththila_token_free (environment, uri);
AXIS2_STACK_PUSH(parser->namesp, environment, ns);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org