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 sa...@apache.org on 2006/12/20 10:42:15 UTC

svn commit: r489002 - /webservices/axis2/trunk/c/util/src/stream.c

Author: samisa
Date: Wed Dec 20 01:42:15 2006
New Revision: 489002

URL: http://svn.apache.org/viewvc?view=rev&rev=489002
Log:
Fixed the memmove to use a buffer head and update the pointer in place of memory move.
AXIS2C-472


Modified:
    webservices/axis2/trunk/c/util/src/stream.c

Modified: webservices/axis2/trunk/c/util/src/stream.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/stream.c?view=diff&rev=489002&r1=489001&r2=489002
==============================================================================
--- webservices/axis2/trunk/c/util/src/stream.c (original)
+++ webservices/axis2/trunk/c/util/src/stream.c Wed Dec 20 01:42:15 2006
@@ -35,6 +35,7 @@
      * instance depending on the type
      */
     axis2_char_t *buffer;
+    axis2_char_t *buffer_head;
     FILE *fp;
     int socket;
 };
@@ -107,6 +108,7 @@
         return NULL;
     }
     stream_impl->buffer = NULL;
+    stream_impl->buffer_head = NULL;
     stream_impl->fp = NULL;
     stream_impl->socket = -1;
     stream_impl->stream.ops = (axis2_stream_ops_t *) AXIS2_MALLOC(
@@ -137,10 +139,11 @@
     {
         case AXIS2_STREAM_BASIC:
         {
-            if (stream_impl->buffer)
+            if (stream_impl->buffer_head)
             {
-                AXIS2_FREE(env->allocator, stream_impl->buffer);
+                AXIS2_FREE(env->allocator, stream_impl->buffer_head);
             }
+            stream_impl->buffer_head = NULL;
             stream_impl->buffer = NULL;
             stream_impl->len = -1;
             break;
@@ -210,6 +213,7 @@
     stream_impl->stream.ops->skip = axis2_stream_skip_basic;
     stream_impl->buffer = (axis2_char_t*)AXIS2_MALLOC(env->allocator,
             AXIS2_STREAM_DEFAULT_BUF_SIZE * sizeof(axis2_char_t));
+    stream_impl->buffer_head = stream_impl->buffer;
     stream_impl->len = 0;
     stream_impl->max_len =    AXIS2_STREAM_DEFAULT_BUF_SIZE;
 
@@ -254,8 +258,7 @@
     * adjust the length of the stream.
     */
     AXIS2_INTF_TO_IMPL(stream)->len -= len;
-    memmove(buf, buf + len * sizeof(axis2_char_t),
-            AXIS2_INTF_TO_IMPL(stream)->len * sizeof(axis2_char_t));
+    AXIS2_INTF_TO_IMPL(stream)->buffer = buf + len;
     ((axis2_char_t *) buffer)[len] = '\0';
     return len;
 }
@@ -290,8 +293,9 @@
          */
         stream_impl->max_len = new_len + AXIS2_STREAM_DEFAULT_BUF_SIZE;
         memcpy(tmp, stream_impl->buffer, sizeof(axis2_char_t)*stream_impl->len);
-        AXIS2_FREE(env->allocator, stream_impl->buffer);
+        AXIS2_FREE(env->allocator, stream_impl->buffer_head);
         stream_impl->buffer = tmp;
+        stream_impl->buffer_head = tmp;
     }
     memcpy(stream_impl->buffer + (stream_impl->len * sizeof(axis2_char_t)),
             buffer, count);
@@ -326,9 +330,7 @@
             del_len = stream_impl->len;
         }
         stream_impl->len -= del_len;
-        memmove(stream_impl->buffer, stream_impl->buffer +
-                del_len * sizeof(axis2_char_t),
-                stream_impl->len * sizeof(axis2_char_t));
+        stream_impl->buffer += del_len;
         return del_len;
     }
     return -1;



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