axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From din...@apache.org
Subject svn commit: r500778 - in /webservices/axis2/trunk/c/guththila: include/ samples/ src/
Date Sun, 28 Jan 2007 11:23:38 GMT
Author: dinesh
Date: Sun Jan 28 03:23:34 2007
New Revision: 500778

URL: http://svn.apache.org/viewvc?view=rev&rev=500778
Log:
memory leaks fixed, correction for writer buffer problem

Modified:
    webservices/axis2/trunk/c/guththila/include/guththila.h
    webservices/axis2/trunk/c/guththila/include/guththila_buffer.h
    webservices/axis2/trunk/c/guththila/include/guththila_token.h
    webservices/axis2/trunk/c/guththila/include/guththila_writer.h
    webservices/axis2/trunk/c/guththila/include/guththila_xml_writer.h
    webservices/axis2/trunk/c/guththila/samples/guththila_main.c
    webservices/axis2/trunk/c/guththila/samples/guththila_writer_main.c
    webservices/axis2/trunk/c/guththila/src/guththila_buffer.c
    webservices/axis2/trunk/c/guththila/src/guththila_token.c
    webservices/axis2/trunk/c/guththila/src/guththila_writer.c
    webservices/axis2/trunk/c/guththila/src/guththila_xml_pull_parser.c
    webservices/axis2/trunk/c/guththila/src/guththila_xml_writer.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=500778&r1=500777&r2=500778
==============================================================================
--- webservices/axis2/trunk/c/guththila/include/guththila.h (original)
+++ webservices/axis2/trunk/c/guththila/include/guththila.h Sun Jan 28 03:23:34 2007
@@ -210,10 +210,10 @@
 guththila_is_space (axis2_env_t *environment, int c);
 
 
-void AXIS2_CALL
+/*void AXIS2_CALL
 guththila_relocate_tokens (axis2_env_t *environment,
                                            guththila_t *p,
-                                           int offset);
+                                           int offset);*/
                                            
 void AXIS2_CALL
 guththila_shift (axis2_env_t *environment,
@@ -485,11 +485,6 @@
 AXIS2_EXTERN void   AXIS2_CALL
 guththila_write_end_element (axis2_env_t *environment, 
 					     guththila_t *p);
-
-
-AXIS2_EXTERN void   AXIS2_CALL
-guththila_flush (axis2_env_t *environment, 
-				 guththila_t *p);
 
 
 AXIS2_EXTERN void  AXIS2_CALL

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=500778&r1=500777&r2=500778
==============================================================================
--- webservices/axis2/trunk/c/guththila/include/guththila_buffer.h (original)
+++ webservices/axis2/trunk/c/guththila/include/guththila_buffer.h Sun Jan 28 03:23:34 2007
@@ -35,7 +35,7 @@
   guththila_char_t *buff;
 } guththila_buffer_t;
 
-#define GUTHTHILA_BUFFER_SIZE 50
+#define GUTHTHILA_BUFFER_SIZE 1024
 
 AXIS2_EXTERN guththila_buffer_t * AXIS2_CALL
 guththila_buffer_create (axis2_env_t * environment, int size);

Modified: webservices/axis2/trunk/c/guththila/include/guththila_token.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/include/guththila_token.h?view=diff&rev=500778&r1=500777&r2=500778
==============================================================================
--- webservices/axis2/trunk/c/guththila/include/guththila_token.h (original)
+++ webservices/axis2/trunk/c/guththila/include/guththila_token.h Sun Jan 28 03:23:34 2007
@@ -25,6 +25,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <axis2_env.h>
+#include <axis2_stack.h>
 #include <guththila_defines.h>
 
 
@@ -119,6 +120,10 @@
 guththila_token_char_ref (axis2_env_t * environment,
                           guththila_char_t * buffer);
                           
+AXIS2_EXTERN void AXIS2_CALL
+guththila_relocate_tokens(axis2_env_t *environment,
+						  axis2_stack_t *stack,
+						  int offset);
 
 #endif /* GUTHTHILA_TOKEN_H */
 

Modified: webservices/axis2/trunk/c/guththila/include/guththila_writer.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/include/guththila_writer.h?view=diff&rev=500778&r1=500777&r2=500778
==============================================================================
--- webservices/axis2/trunk/c/guththila/include/guththila_writer.h (original)
+++ webservices/axis2/trunk/c/guththila/include/guththila_writer.h Sun Jan 28 03:23:34 2007
@@ -73,3 +73,6 @@
 								  guththila_writer_t *wt);
 
 #endif	/* GUTHTHILA_WRITE_H */
+
+
+

Modified: webservices/axis2/trunk/c/guththila/include/guththila_xml_writer.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/include/guththila_xml_writer.h?view=diff&rev=500778&r1=500777&r2=500778
==============================================================================
--- webservices/axis2/trunk/c/guththila/include/guththila_xml_writer.h (original)
+++ webservices/axis2/trunk/c/guththila/include/guththila_xml_writer.h Sun Jan 28 03:23:34
2007
@@ -29,9 +29,7 @@
 	axis2_stack_t *attribute;
 	axis2_stack_t *namespace;
 	axis2_stack_t *depth;
-	axis2_stack_t *other;
 	guththila_writer_t *writer;
-	guththila_buffer_t *writer_buffer;
 	int next;
 	int last;
 	int offset;

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=500778&r1=500777&r2=500778
==============================================================================
--- webservices/axis2/trunk/c/guththila/samples/guththila_main.c (original)
+++ webservices/axis2/trunk/c/guththila/samples/guththila_main.c Sun Jan 28 03:23:34 2007
@@ -103,7 +103,7 @@
                 {
                     /* p = guththila_get_attribute_prefix_by_number
                        (parser, ia); */
-                    p = guththila_get_attribute_namespace_by_number(environment, parser,
ia);
+                    p =	guththila_get_attribute_prefix_by_number(environment, parser, ia);
                     if (p)
                     {
                         printf(" %s:", p);
@@ -171,14 +171,14 @@
             break;
             case GUTHTHILA_CHARACTER:
             {
-                char *p;
+                char *p = NULL;
                 p = guththila_get_value(environment, parser);
-             /*    if (!parser->is_whitespace) */
-/*                 { */
-/*                     printf(p); */
-/*                 } */
-				printf (p);
-                AXIS2_FREE(allocator, p);
+				/*    if (!parser->is_whitespace) */
+				/*                 { */
+				/*                     printf(p); */
+				/*                 } */
+				printf ("%s",p);
+				AXIS2_FREE(allocator, p);
             }
             break;
             case GUTHTHILA_COMMENT:

Modified: webservices/axis2/trunk/c/guththila/samples/guththila_writer_main.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/samples/guththila_writer_main.c?view=diff&rev=500778&r1=500777&r2=500778
==============================================================================
--- webservices/axis2/trunk/c/guththila/samples/guththila_writer_main.c (original)
+++ webservices/axis2/trunk/c/guththila/samples/guththila_writer_main.c Sun Jan 28 03:23:34
2007
@@ -21,29 +21,44 @@
 #include <guththila_writer.h>
 #include <guththila.h>
 #include <axis2_util.h>
-int main()
+#define MAXA 100000
+int main(int argc, char *argv[])
 {
     char *t;
     axis2_allocator_t *allocator;
     axis2_env_t *env ;
     guththila_t *parser ;
-    /*guththila_writer_t *writer;*/
+	char *xml = NULL;
+	FILE *file = NULL;
     allocator = axis2_allocator_init(NULL);
     env = axis2_env_create(allocator);
-    /*writer = guththila_writer_create_for_memory (env);*/
     parser = guththila_create(env, NULL);
 	guththila_create_xml_stream_writer_for_memory(env, parser);
-// guththila_write_start_element_with_prefix (env, parser, "my", "one");
-	 guththila_write_start_element(env, parser, "two");
+	guththila_write_start_element(env, parser, "two");
     guththila_write_default_namespace(env, parser, "http://another.host.com");
-    guththila_write_start_element(env, parser, "two.one");
-    guththila_write_end_element(env, parser);
+	guththila_write_start_element_with_prefix_and_namespace (env, parser, "ws", "http://www.wso2.org",
"wso2");
+	guththila_write_start_element_with_prefix (env, parser, "ws", "stacks");
+	guththila_write_attribute_with_prefix (env, parser, "ws", "stack", "axis2");
+	guththila_write_characters (env, parser, "testadfjaldjf;ajf;lkajdfa;lkjfd;ajdf11111111111122334455");
     guththila_write_end_document(env, parser);
-	/*guththila_write_to_buffer (env, parser, xml);
-	  guththila_flush (env, parser);*/
+
+	xml = (char *) AXIS2_MALLOC (env->allocator, MAXA + 1);
+	memset (xml, 0, MAXA + 1);
+	if (!argv[1])
+	{
+		file = fopen ("/home/dinesh/tmp/mbox_backup/mbox.archived", "r");
+	}
+	else
+		file = fopen (argv[1], "r");
+
+	if (file)
+		fread (xml, 1, MAXA, file);
+
+	guththila_write_to_buffer (env, parser, xml);
     t = guththila_writer_get_buffer(env, parser->xsw->writer);
     printf("%s \n", t);
-	AXIS2_FREE (env->allocator, t);
+	free (xml);
+	fclose (file);
     guththila_xml_writer_free(env, parser);
     guththila_free(env, parser);
     axis2_env_free(env);

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=500778&r1=500777&r2=500778
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_buffer.c (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_buffer.c Sun Jan 28 03:23:34 2007
@@ -41,7 +41,7 @@
 		{
             name->buff = (guththila_char_t *) AXIS2_MALLOC(
 				environment->allocator, (size+1) * sizeof (guththila_char_t));
-			name->buff [size] = 0;
+			memset (name->buff, 0, size + 1);
 		}
     }
     return name;
@@ -92,21 +92,22 @@
 {
 
     guththila_char_t *x = NULL;
+	unsigned int length = 0;
+	length = strlen (name->buff);
+	name->size <<= 1;
 
-    name->size <<= 1;
-
-	if (buffer_length > name->size)
+	if (length + buffer_length > name->size)
 	{
 		name->size += buffer_length;
 	}
 
     x = (guththila_char_t *) AXIS2_MALLOC(environment->allocator, name->size + 1);
-	x[name->size] = 0;
 
     if (x)
 	{
-		memcpy (x, name->buff, strlen (name->buff));
-        name->buff = x;
+		memset (x, 0, name->size + 1);
+		memcpy (x, name->buff, length);
+		name->buff = x;
 	}
     else
         name->size >>= 1;

Modified: webservices/axis2/trunk/c/guththila/src/guththila_token.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_token.c?view=diff&rev=500778&r1=500777&r2=500778
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_token.c (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_token.c Sun Jan 28 03:23:34 2007
@@ -122,16 +122,16 @@
 guththila_token_char_ref(axis2_env_t * environment,
         guththila_char_t * buffer)
 {
-    int len;
-    int ii;
-    int ix;
+    int len = 0;
+    int ii = 0;
+    int ix = 0;
     guththila_char_t *ref_buffer = NULL;
 
     len = AXIS2_STRLEN(buffer);
     ref_buffer = (guththila_char_t *) AXIS2_MALLOC(
                 environment->allocator, len + 1);
 
-
+	ref_buffer[len] = 0;
     for (ii = 0, ix = 0; ii < len; ii++, ix++)
     {
         if (buffer[ii] == '&')
@@ -177,6 +177,7 @@
         else
             ref_buffer[ix] = buffer[ii];
     }
+	AXIS2_FREE (environment->allocator, buffer);
     return ref_buffer;
 }
 
@@ -343,4 +344,22 @@
         output_buffer = strcat(output_buffer, output_char);
     }
     return output_buffer;
+}
+
+AXIS2_EXTERN void AXIS2_CALL
+guththila_relocate_tokens(axis2_env_t *environment,
+						  axis2_stack_t *stack,
+						  int offset)
+{
+    guththila_token_t *el = NULL;
+    int isize = 0;
+    isize = AXIS2_STACK_SIZE(stack, environment);
+    /*   el = (guththila_token_t *) AXIS2_STACK_GET_AT (stack, environment, isize-1); */
+    for (; isize > 0; isize--)
+    {
+        el = (guththila_token_t *) AXIS2_STACK_GET_AT(stack, 
+													  environment, 
+													  isize - 1);
+        guththila_token_relocate(environment, el, offset);
+    }
 }

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=500778&r1=500777&r2=500778
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_writer.c (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_writer.c Sun Jan 28 03:23:34 2007
@@ -74,11 +74,12 @@
 
 AXIS2_EXTERN int AXIS2_CALL
 guththila_writer_write(axis2_env_t *env,
-        char *buffer, int offset,
-        int length, guththila_writer_t *wt)
+					   char *buffer, int offset,
+					   int length, guththila_writer_t *wt)
 {
     int c = 0;
     guththila_writer_impl_t *writer_impl = NULL;
+
     if (wt->guththila_writer_type == GUTHTHILA_WRITER_FILE)
     {
         c = fwrite(buffer + offset, 1, length, ((guththila_writer_impl_t *)wt)->outputstream);
@@ -86,19 +87,16 @@
     else if (wt->guththila_writer_type == GUTHTHILA_WRITER_MEMORY)
     {
         int size = 0;
+/* 		int buffer_len = 0; */
+/* 		buffer_len = strlen (buffer); */
         writer_impl = (guththila_writer_impl_t *)wt;
 
 		 if (writer_impl->buffer->buff)
 			 size = writer_impl->buffer->next;
 
-        if ((size + length) > writer_impl->buffer->size)
-        {
-            writer_impl->buffer = guththila_buffer_grow(env, writer_impl->buffer, length);
-        }
-
 		if (buffer)
 		{
-			memcpy (writer_impl->buffer->buff + size, buffer, strlen (buffer));
+			memcpy (writer_impl->buffer->buff + size, buffer, length);
 			writer_impl->buffer->next += length;
 			c = length;
 		}
@@ -115,7 +113,9 @@
     writer_impl = (guththila_writer_impl_t *)wt;
 
     if (writer_impl->buffer->buff)
+	{
         return (char *)writer_impl->buffer->buff;
+	}
     else
         return (char *)NULL;
 }
@@ -132,10 +132,3 @@
 		size = (unsigned int) writer_impl->buffer->next;
 	return size;
 }
-
-
-
-
-
-
-

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=500778&r1=500777&r2=500778
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_xml_pull_parser.c (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_xml_pull_parser.c Sun Jan 28 03:23:34
2007
@@ -148,7 +148,6 @@
         AXIS2_STACK_FREE(parser->other, environment);
 	}
 
-
     AXIS2_FREE(environment->allocator, (void *) parser);
 }
 
@@ -162,23 +161,6 @@
 }
 
 
-void AXIS2_CALL
-guththila_relocate_tokens(axis2_env_t *environment,
-						  guththila_t *parser,
-						  int offset)
-{
-    guththila_token_t *el = NULL;
-    int isize = 0;
-    isize = AXIS2_STACK_SIZE(parser->stack, environment);
-    /*   el = (guththila_token_t *) AXIS2_STACK_GET_AT (parser->stack, environment, isize-1);
*/
-    for (; isize > 0; isize--)
-    {
-        el = (guththila_token_t *) AXIS2_STACK_GET_AT(parser->stack, 
-													  environment, 
-													  isize - 1);
-        guththila_token_relocate(environment, el, offset);
-    }
-}
 
 
 void AXIS2_CALL
@@ -202,7 +184,7 @@
     {
         if (parser->offset > 0)
         {
-            guththila_relocate_tokens(environment, parser,
+            guththila_relocate_tokens(environment, parser->stack,
 									  parser->offset);
             guththila_shift(environment, parser);
         }
@@ -214,7 +196,7 @@
 			b = parser->buffer->size;
             parser->buffer =
                 guththila_buffer_grow(environment, parser->buffer, parser->_next);
-			guththila_relocate_tokens(environment, parser, 
+			guththila_relocate_tokens(environment, parser->stack, 
 									  (buff - parser->buffer->buff));
 			AXIS2_STACK_PUSH(parser->other, environment, buff);
         }
@@ -1050,8 +1032,8 @@
                         guththila_add_namespace(environment,
 												parser, name,
 												value);
-						guththila_token_free (environment, name);
-						guththila_token_free (environment, value);
+					guththila_token_free (environment, name);
+					guththila_token_free (environment, value);
 					}
                     else
                         guththila_add_attribute(environment,
@@ -1081,6 +1063,7 @@
 												attribute->
 												value);
 						guththila_attribute_free (environment, attribute);
+						guththila_token_free (environment, token);
                     }
                     else
                     {
@@ -1092,6 +1075,7 @@
                             guththila_add_attribute_with_prefix
 								(environment, parser, token,
 								 attribute->name, attribute->value);
+							AXIS2_STACK_PUSH (parser->other, environment, (void *) attribute);
                         }
                     }
                 }

Modified: webservices/axis2/trunk/c/guththila/src/guththila_xml_writer.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_xml_writer.c?view=diff&rev=500778&r1=500777&r2=500778
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_xml_writer.c (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_xml_writer.c Sun Jan 28 03:23:34 2007
@@ -26,13 +26,10 @@
         p->xsw = (guththila_xml_writer_t *) AXIS2_MALLOC(env->allocator, 
 														 sizeof(guththila_xml_writer_t));
         p->xsw->writer = guththila_writer_create_for_file(env, file);
-        p->xsw->writer_buffer = guththila_buffer_create(env, GUTHTHILA_BUFFER_SIZE);
-        p->xsw->writer_buffer->buff[0] = 0;
         p->xsw->element = axis2_stack_create(env);
         p->xsw->attribute = axis2_stack_create(env);
         p->xsw->namespace = axis2_stack_create(env);
         p->xsw->depth = axis2_stack_create(env);
-        p->xsw->other = axis2_stack_create(env);
         p->xsw->next = 0;
         p->xsw->offset = 0;
         p->xsw->last = GUTHTHILA_BUFFER_SIZE;	/* size of the buffer */
@@ -52,13 +49,10 @@
         p->xsw = (guththila_xml_writer_t *) AXIS2_MALLOC(env->allocator, 
 														 sizeof(guththila_xml_writer_t));
         p->xsw->writer = guththila_writer_create_for_memory(env);
-        p->xsw->writer_buffer = guththila_buffer_create(env, GUTHTHILA_BUFFER_SIZE);
-        p->xsw->writer_buffer->buff[0] = 0;
         p->xsw->element = axis2_stack_create(env);
         p->xsw->attribute = axis2_stack_create(env);
         p->xsw->namespace = axis2_stack_create(env);
         p->xsw->depth = axis2_stack_create(env);
-        p->xsw->other = axis2_stack_create(env);
         p->xsw->next = 0;
         p->xsw->offset = 0;
         p->xsw->last = GUTHTHILA_BUFFER_SIZE;	/* size of the buffer */
@@ -79,12 +73,7 @@
     
     /*   guththila_flush (env, p); */
     guththila_write_end_document(env, p);
-    if (p->xsw->writer_buffer)
-    {
-        guththila_buffer_free(env, p->xsw->writer_buffer);
-        p->xsw->writer_buffer = NULL;
-    }
-
+    
     if (p->xsw->element)
     {
         void *element;
@@ -162,26 +151,6 @@
 
     }
 
-    if (p->xsw->other)
-    {
-        void *element;
-        size = 0;
-
-        size = AXIS2_STACK_SIZE(p->xsw->other, env);
-        if (size)
-        {
-            for (; size > 0; size--)
-            {
-                element = AXIS2_STACK_POP(p->xsw->other, env);
-                AXIS2_FREE(env->allocator, element);
-                element = NULL;
-            }
-        }
-        AXIS2_STACK_FREE(p->xsw->other, env);
-        p->xsw->other = NULL;
-    }
-
-
     if (p->xsw->writer)
     {
         guththila_writer_free(env, p->xsw->writer);
@@ -210,7 +179,7 @@
 
 AXIS2_EXTERN void AXIS2_CALL
 guththila_write_start_document(axis2_env_t *env,
-        guththila_t *p)
+							   guththila_t *p)
 {
     char *sd =  NULL;
     
@@ -246,24 +215,6 @@
 
 
 AXIS2_EXTERN void AXIS2_CALL
-guththila_flush(axis2_env_t *env, guththila_t *p)
-{
-    int c;
-    int ii = 0;
-    
-    if (p->xsw->writer_buffer->buff)
-    {
-        ii = p->xsw->next;
-        c = guththila_writer_write(env, p->xsw->writer_buffer->buff, 0, ii, p->xsw->writer);
-        p->xsw->writer_buffer->buff[0] = 0;
-        p->xsw->writer_buffer->buff[1] = 0;
-        p->xsw->next = 0;
-        p->xsw->offset = 0;
-    }
-}
-
-
-AXIS2_EXTERN void AXIS2_CALL
 guththila_write_start_element(axis2_env_t *env, guththila_t *p, char *start_element)
 {
     int size;
@@ -298,26 +249,33 @@
 AXIS2_EXTERN void  AXIS2_CALL
 guththila_write_to_buffer(axis2_env_t *env, guththila_t *p, const char *buff)
 {
+    int c = 0;
+    int ii = 0;
+    guththila_writer_impl_t *writer_impl;
+	unsigned int size = 0;
+	guththila_char_t *init_buffer = NULL;
     if (buff)
     {
-        int length = 0;
-        
-        length = strlen(buff);
-
-        if ((p->xsw->next + length) >= p->xsw->last)
-        {
-            guththila_flush(env, p);
-            p->xsw->next = 0;
-            p->xsw->offset = 0;
-        }
-
-        if (p->xsw->writer_buffer->buff && p->xsw->next > -1)
-        {
-            memcpy ((p->xsw->writer_buffer->buff) + (p->xsw->next), buff,
length);
-            p->xsw->offset = p->xsw->next;
-            p->xsw->next += length;
-        }
-    }
+        ii = strlen (buff);
+		if (p->xsw->writer->guththila_writer_type == GUTHTHILA_WRITER_MEMORY)
+		{
+			writer_impl = (guththila_writer_impl_t *)p->xsw->writer;
+			
+			if (writer_impl->buffer->buff)
+				size = writer_impl->buffer->next;
+			
+			if ((size + ii) > writer_impl->buffer->size)
+			{
+				init_buffer = writer_impl->buffer->buff;
+				writer_impl->buffer = guththila_buffer_grow(env, writer_impl->buffer, ii);
+				p->xsw->last = writer_impl->buffer->size;
+ 				AXIS2_STACK_PUSH (p->other, env, init_buffer);;
+			}
+		}
+        c = guththila_writer_write(env, (char *)buff, 0, ii, p->xsw->writer);
+		p->xsw->offset = p->xsw->next;
+		p->xsw->next += c;
+	}
 }
 
 
@@ -362,7 +320,7 @@
             for (;stack_size > 0; stack_size--)
             {
                 att = (guththila_attribute_t *)AXIS2_STACK_POP(p->xsw->attribute, env);
-                AXIS2_FREE(env->allocator, att);
+/* 				guththila_attribute_free (env, att); */
                 att = NULL;
             }
         }
@@ -392,17 +350,17 @@
 
     /* xml in any case combination isn't allow */
     if ((name[0] == 'x' || name[0] == 'X')
-            && (name[1] == 'm' || name[1] == 'M')
-            && (name[2] == 'l' || name[2] == 'L'))
+		&& (name[1] == 'm' || name[1] == 'M')
+		&& (name[2] == 'l' || name[2] == 'L'))
         guththila_exception(p_FILE, LINE, GUTHTHILA_WRITER_ERROR_XML_STRING_IN_NAME);
 
     /* some punctuation's not allowed */
     for (ii = 1; ii < length; ii++)
     {
         if ((name[ii] == '$' || name[ii] == '^' || name[ii] == '%'
-                || name[ii] == ';' || name[ii] == '\'' || name[ii] == '"'
-                || name[ii] == '&' || name[ii] == '<' || name[ii] == '>'
-                || isspace(name[ii])))
+			 || name[ii] == ';' || name[ii] == '\'' || name[ii] == '"'
+			 || name[ii] == '&' || name[ii] == '<' || name[ii] == '>'
+			 || isspace(name[ii])))
             guththila_exception(p_FILE, LINE, GUTHTHILA_WRITER_ERROR_INVALID_CHAR_IN_NAME);
     }
 }
@@ -527,9 +485,9 @@
 
 void AXIS2_CALL
 guththila_do_write_attribute(axis2_env_t *env,
-        guththila_t *p,
-        const char *local_name,
-        const char *value)
+							 guththila_t *p,
+							 const char *local_name,
+							 const char *value)
 {
     guththila_attribute_t *attr = (guththila_attribute_t *) AXIS2_MALLOC(env->allocator,
sizeof(guththila_attribute_t));
 
@@ -539,14 +497,14 @@
         attr->value = (guththila_token_t *)value;
     if (local_name && value)
     {
-        AXIS2_STACK_PUSH(p->xsw->attribute, env, (void *)attr);
+        AXIS2_STACK_PUSH(p->xsw->attribute, env, attr);
     }
 
     guththila_check_name_validity(env, p, (char *)local_name);
 
     if (strrchr(value, '&')
-            || strrchr(value, '<')
-            || strrchr(value, '\"'))
+		|| strrchr(value, '<')
+		|| strrchr(value, '\"'))
         guththila_exception(p_FILE, LINE, GUTHTHILA_WRITER_ERROR_INVALID_CHAR_IN_ATTRIBUTE);
 
     guththila_write_to_buffer(env, p, " ");
@@ -627,7 +585,7 @@
 
     guththila_write_to_buffer(env, p, " ");
     guththila_write_to_buffer(env, p, "xmlns");
-    guththila_write_to_buffer(env, p, " = \'");
+    guththila_write_to_buffer(env, p, "=\'");
     guththila_write_to_buffer(env, p, ns_uri);
     guththila_write_to_buffer(env, p, "\'");
 }
@@ -711,8 +669,8 @@
 
 AXIS2_EXTERN void AXIS2_CALL
 guththila_write_attribute_with_prefix_and_namespace(axis2_env_t *env, guththila_t *p,
-        const char *prefix, const char *namespace,
-        const char *local_name, const char *value)
+													const char *prefix, const char *namespace,
+													const char *local_name, const char *value)
 {
     int size = 0;
     void *element;
@@ -735,7 +693,7 @@
             {
                 attr = (guththila_attribute_t *)element;
                 /* We want to make sure that out checking attribute has
-                the prefix otherwise we don't wan't to worry */
+				   the prefix otherwise we don't wan't to worry */
                 if (attr->name && attr->prefix)
                 {
                     if (!strcmp((char *)attr->name, local_name) && !strcmp((char
*)attr->prefix, prefix))
@@ -766,8 +724,8 @@
 
 void AXIS2_CALL
 guththila_do_write_attribute_with_prefix_and_namespace(axis2_env_t *env, guththila_t *p,
-        const char *prefix, const char *namespace_uri,
-        const char *local_name, const char *value)
+													   const char *prefix, const char *namespace_uri,
+													   const char *local_name, const char *value)
 {
     guththila_attribute_t *attr = (guththila_attribute_t *) AXIS2_MALLOC(env->allocator,
sizeof(guththila_attribute_t));
 
@@ -780,18 +738,13 @@
     if (value)
         attr->value = (guththila_token_t *)value;
 
-    if (local_name && value)
-    {
-        AXIS2_STACK_PUSH(p->xsw->attribute, env, (void *)attr);
-    }
-    else
-        guththila_exception(p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EMPTY_ARGUMENTS);
-
-    guththila_check_name_validity(env, p, (char *)local_name);
+	AXIS2_STACK_PUSH(p->xsw->attribute, env, (void *)attr);
+	AXIS2_STACK_PUSH(p->other, env, attr);
+	guththila_check_name_validity(env, p, (char *)local_name);
 
     if (strrchr(value, '&')
-            || strrchr(value, '<')
-            || strrchr(value, '\''))
+		|| strrchr(value, '<')
+		|| strrchr(value, '\''))
         guththila_exception(p_FILE, LINE, GUTHTHILA_WRITER_ERROR_INVALID_CHAR_IN_ATTRIBUTE);
 
     guththila_write_to_buffer(env, p, " ");
@@ -804,13 +757,12 @@
     guththila_write_to_buffer(env, p, " = \'");
     guththila_write_to_buffer(env, p, value);
     guththila_write_to_buffer(env, p, "\'");
-
 }
 
 
 AXIS2_EXTERN void AXIS2_CALL
 guththila_write_attribute_with_prefix(axis2_env_t *env, guththila_t *p, const char *prefix,
-        const char *local_name, const char *value)
+									  const char *local_name, const char *value)
 {
     int size = 0;
     void *element;
@@ -867,7 +819,7 @@
 
 void AXIS2_CALL
 guththila_do_write_attribute_with_prefix(axis2_env_t *env, guththila_t *p, const char *prefix,
-        const char *local_name, const char *value)
+										 const char *local_name, const char *value)
 {
     guththila_do_write_attribute_with_prefix_and_namespace(env, p, prefix, NULL, local_name,
value);
 }
@@ -935,7 +887,7 @@
 
 AXIS2_EXTERN void AXIS2_CALL
 guththila_write_attribute_with_namespace(axis2_env_t *env, guththila_t *p, const char *namespace,
-        const char *local_name, const char *value)
+										 const char *local_name, const char *value)
 {
     int size = 0;
     void *element;
@@ -1023,7 +975,7 @@
 
 AXIS2_EXTERN void AXIS2_CALL
 guththila_write_start_element_with_prefix_and_namespace(axis2_env_t *env, guththila_t *p,
const char *prefix,
-        const char *namespace_uri, const char *local_name)
+														const char *namespace_uri, const char *local_name)
 {
     int size;
     void *element;
@@ -1049,7 +1001,7 @@
         guththila_open_depth_element(env, p);
 
         if (prefix)
-        {
+        { 
 			memcpy (start_element, prefix, prefix_length);
             memcpy (start_element + prefix_length, ":", 1);
             memcpy (start_element + (prefix_length + 1), local_name, name_length);
@@ -1067,7 +1019,7 @@
                     guththila_exception(p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_MATCHING_ELEMENTS);
             }
         }
-		AXIS2_STACK_PUSH(p->xsw->other, env, start_element);
+		AXIS2_STACK_PUSH(p->other, env, start_element);
         guththila_check_name_validity(env, p, start_element);
         p->xsw->start_element_open = 1;
 
@@ -1135,33 +1087,41 @@
 
 
 AXIS2_EXTERN void AXIS2_CALL
-guththila_write_start_element_with_prefix(axis2_env_t *env, guththila_t *p, const char *prefix,
const char *local_name)
+guththila_write_start_element_with_prefix (axis2_env_t *env, guththila_t *p, const char *prefix,
const char *local_name)
 {
     int size;
     void *element;
     char *start_element = NULL;
+	unsigned int prefix_length = 0;
+	unsigned int name_length = 0;
+	unsigned int length = 0;
+
     if (guththila_is_exsisting_prefix(env, p, prefix))
     {
-        if (!p || !local_name)
-            guththila_exception(p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EMPTY_ARGUMENTS);
-        else
-        {
-            
-            guththila_close_start_element(env, p);
-            guththila_open_depth_element(env, p);
 
-            if (prefix)
-            {
-                start_element = (char *) AXIS2_MALLOC(env->allocator, (strlen(prefix)
+ strlen(local_name) + 2));
-                memset(start_element, 1, strlen(start_element));
-            }
+    if (prefix && local_name)
+	{
+		prefix_length = strlen(prefix);
+		name_length = strlen (local_name);
+		length = prefix_length + name_length + 2;
+        start_element = (char *) AXIS2_MALLOC (env->allocator, length);
+		memset (start_element, 0, length);
+	}
+
+	if (!p || !local_name)
+		guththila_exception(p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EMPTY_ARGUMENTS);
+	else
+	{
+		guththila_close_start_element(env, p);
+		guththila_open_depth_element(env, p);
+		
+		if (prefix)
+		{
+			memcpy (start_element, prefix, prefix_length);
+            memcpy (start_element + prefix_length, ":", 1);
+            memcpy (start_element + (prefix_length + 1), local_name, name_length);
+		}
 
-            if (prefix)
-            {
-                strcat(start_element, prefix);
-                strcat(start_element, ":");
-                strcat(start_element, local_name);
-            }
             size = AXIS2_STACK_SIZE(p->xsw->element, env);
             if (size)
             {
@@ -1170,7 +1130,7 @@
                     guththila_exception(p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_MATCHING_ELEMENTS);
             }
 
-			AXIS2_STACK_PUSH(p->xsw->other, env, start_element);
+			AXIS2_STACK_PUSH(p->other, env, start_element);
             guththila_check_name_validity(env, p, start_element);
             p->xsw->start_element_open = 1;
 
@@ -1187,7 +1147,7 @@
 
 AXIS2_EXTERN void AXIS2_CALL
 guththila_write_empty_element_with_prefix_and_namespace(axis2_env_t *env, guththila_t *p,
const char *prefix,
-        const char *namespace_uri, const char *empty_element)
+														const char *namespace_uri, const char *empty_element)
 {
     
     guththila_close_start_element(env, p);
@@ -1274,15 +1234,15 @@
     ii = AXIS2_STACK_SIZE(p->xsw->element, env);
     for (; ii > 0; ii --)
         guththila_write_end_element(env, p);
-    guththila_flush(env, p);
+/*     guththila_flush(env, p); */
 }
 
 
 AXIS2_EXTERN void AXIS2_CALL
 guththila_close(axis2_env_t *env,
-        guththila_t *p)
+				guththila_t *p)
 {
-    guththila_flush(env, p);
+/*     guththila_flush(env, p); */
     fclose(((guththila_writer_impl_t *)p->xsw->writer)->outputstream);
 }
 
@@ -1300,10 +1260,8 @@
 guththila_get_memory_buffer(axis2_env_t *env, guththila_t *p)
 {
     char *buffer = NULL;
-    guththila_flush(env, p);
     if (p->xsw)
         buffer = guththila_writer_get_buffer(env, p->xsw->writer);
-
     return buffer;
 }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message