No need to free priv->recv_buf as it is now done in
authorAlex Graveley <alex@ximian.com>
Fri, 25 May 2001 05:36:36 +0000 (05:36 +0000)
committerAlex Graveley <orph@src.gnome.org>
Fri, 25 May 2001 05:36:36 +0000 (05:36 +0000)
2001-05-25  Alex Graveley  <alex@ximian.com>

* src/soup-core/soup-queue.c (soup_message_queue): No need to free
priv->recv_buf as it is now done in soup_message_cleanup().
(soup_message_queue): Free response_header keys and values before
destroying the hash table.

* src/soup-core/soup-message.c (soup_message_free): Don't free
priv->recv_buf here.
(soup_message_cleanup): Free priv->recv_buf here instead.

* src/soup-core/soup-queue.c (soup_finish_read): Since we now
g_strdup() all headers, and we already g_memdup the actual body
buffer, free the temporary recv_buf.

* src/soup-core/soup-headers.c (soup_headers_parse_response):
g_strdup() the response reason phrase.

ChangeLog
libsoup/soup-headers.c
libsoup/soup-message.c
libsoup/soup-queue.c

index e915da1..f57ee8a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2001-05-25  Alex Graveley  <alex@ximian.com>
+
+       * src/soup-core/soup-queue.c (soup_message_queue): No need to free
+       priv->recv_buf as it is now done in soup_message_cleanup().
+       (soup_message_queue): Free response_header keys and values before
+       destroying the hash table.
+
+       * src/soup-core/soup-message.c (soup_message_free): Don't free
+       priv->recv_buf here.
+       (soup_message_cleanup): Free priv->recv_buf here instead.
+
+       * src/soup-core/soup-queue.c (soup_finish_read): Since we now
+       g_strdup() all headers, and we already g_memdup the actual body
+       buffer, free the temporary recv_buf.
+
+       * src/soup-core/soup-headers.c (soup_headers_parse_response):
+       g_strdup() the response reason phrase.
+
 2001-05-24  Alex Graveley  <alex@ximian.com>
 
        * README: Update Licensing section for soup-ssl-proxy.
index 6594d38..c37eaff 100644 (file)
@@ -161,7 +161,7 @@ soup_headers_parse_response (gchar        *str,
        if (!soup_headers_parse (str, len, dest)) 
                goto THROW_MALFORMED_HEADER;
 
-       *status_phrase = &str [phrase_start];
+       *status_phrase = g_strdup (&str [phrase_start]);
 
        return TRUE;
 
index 7e91967..c792f38 100644 (file)
@@ -92,13 +92,19 @@ soup_message_cleanup (SoupMessage *req)
        source_remove (req->priv->error_tag);
        source_remove (req->priv->timeout_tag);
 
-       if (req->priv->connect_tag) 
+       if (req->priv->connect_tag) {
                soup_context_cancel_connect (req->priv->connect_tag);
-       if (req->priv->conn) 
+               req->priv->connect_tag = NULL;
+       }
+       if (req->priv->conn) {
                soup_connection_release (req->priv->conn);
+               req->priv->conn = NULL;
+       }
+       if (req->priv->recv_buf) {
+               g_byte_array_free (req->priv->recv_buf, TRUE);
+               req->priv->recv_buf = NULL;
+       }
 
-       req->priv->connect_tag = NULL;
-       req->priv->conn = NULL;
        req->priv->write_len = 0;
        req->priv->header_len = 0;
        req->priv->content_length = 0;
@@ -154,9 +160,6 @@ soup_message_free (SoupMessage *req)
                g_hash_table_destroy (req->response_headers);
        }
 
-       if (req->priv->recv_buf) 
-               g_byte_array_free (req->priv->recv_buf, TRUE);
-
        g_free (req->priv);
        g_free (req->action);
        g_free (req);
index c1f0aa3..aea436c 100644 (file)
@@ -189,10 +189,10 @@ soup_finish_read (SoupMessage *req)
        req->response.body = g_memdup (&arr->data [index],
                                       req->response.length + 1);
        req->response.body [req->response.length] = '\0';
-       
-       /* Headers are zero-terminated */
-       g_byte_array_set_size (arr, index);
-       
+
+       g_byte_array_free (arr, TRUE);
+       req->priv->recv_buf = NULL;
+
        req->status = SOUP_STATUS_FINISHED;
        soup_message_issue_callback (req, SOUP_ERROR_NONE);
 }
@@ -590,6 +590,13 @@ soup_idle_handle_new_requests (gpointer unused)
        return FALSE;
 }
 
+static void
+soup_queue_remove_header (gchar *name, gchar *value, gpointer unused)
+{
+       g_free (name);
+       g_free (value);
+}
+
 /**
  * soup_message_queue:
  * @req: a %SoupMessage.
@@ -641,14 +648,16 @@ soup_message_queue (SoupMessage    *req,
        req->response.body = NULL;
        req->response.length = 0;
 
-       if (req->response_headers)
+       if (req->response_headers) {
+               g_hash_table_foreach (req->response_headers,
+                                     (GHFunc) soup_queue_remove_header,
+                                     NULL);
                g_hash_table_destroy (req->response_headers);
-       if (req->priv->recv_buf) 
-               g_byte_array_free (req->priv->recv_buf, TRUE);
+               req->response_headers = NULL;
+       }
 
        req->response_code = 0;
        req->response_phrase = NULL;
-       req->response_headers = NULL;
        req->priv->recv_buf = NULL;
        req->status = SOUP_STATUS_QUEUED;