[libsoup/carlosgc/clean-refcounted: 1/2] server: make soup_message_body_new/free private




commit c9b73aba1cf537b9a8867d2f70bf604ed9c710e7
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Wed Mar 24 10:58:38 2021 +0100

    server: make soup_message_body_new/free private
    
    SoupMessageBody is created and always owned by SoupServerMessage.

 docs/reference/libsoup-3.0-sections.txt    |  4 ----
 docs/reference/meson.build                 |  1 +
 libsoup/server/soup-message-body-private.h | 16 ++++++++++++++++
 libsoup/server/soup-message-body.c         | 23 ++++-------------------
 libsoup/server/soup-message-body.h         |  8 --------
 libsoup/server/soup-server-message.c       |  5 +++--
 6 files changed, 24 insertions(+), 33 deletions(-)
---
diff --git a/docs/reference/libsoup-3.0-sections.txt b/docs/reference/libsoup-3.0-sections.txt
index 0e963653..f5a5a12e 100644
--- a/docs/reference/libsoup-3.0-sections.txt
+++ b/docs/reference/libsoup-3.0-sections.txt
@@ -174,10 +174,6 @@ soup_header_g_string_append_param_quoted
 <TITLE>SoupMessageBody</TITLE>
 SoupMemoryUse
 <SUBSECTION>
-SoupMessageBody
-soup_message_body_new
-soup_message_body_free
-<SUBSECTION>
 soup_message_body_set_accumulate
 soup_message_body_get_accumulate
 <SUBSECTION>
diff --git a/docs/reference/meson.build b/docs/reference/meson.build
index 40a98944..ee919100 100644
--- a/docs/reference/meson.build
+++ b/docs/reference/meson.build
@@ -3,6 +3,7 @@ ignore_headers = [
   'soup.h',
   'soup-enum-types.h',
   'soup-message-private.h',
+  'soup-message-body-private.h',
   'soup-session-private.h',
   'soup-auth-digest-private.h',
   'soup-brotli-decompressor.h',
diff --git a/libsoup/server/soup-message-body-private.h b/libsoup/server/soup-message-body-private.h
new file mode 100644
index 00000000..bd09fcfb
--- /dev/null
+++ b/libsoup/server/soup-message-body-private.h
@@ -0,0 +1,16 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2000-2003, Ximian, Inc.
+ */
+
+#pragma once
+
+#include "soup-message-body.h"
+
+G_BEGIN_DECLS
+
+SoupMessageBody *soup_message_body_new   (void);
+
+void             soup_message_body_unref (SoupMessageBody *body);
+
+G_END_DECLS
diff --git a/libsoup/server/soup-message-body.c b/libsoup/server/soup-message-body.c
index 28ef1bf3..0924aa83 100644
--- a/libsoup/server/soup-message-body.c
+++ b/libsoup/server/soup-message-body.c
@@ -11,7 +11,7 @@
 
 #include <string.h>
 
-#include "soup-message-body.h"
+#include "soup-message-body-private.h"
 #include "soup.h"
 
 /**
@@ -64,14 +64,6 @@ typedef struct {
        goffset base_offset;
 } SoupMessageBodyPrivate;
 
-/**
- * soup_message_body_new:
- *
- * Creates a new #SoupMessageBody. #SoupMessage uses this internally; you
- * will not normally need to call it yourself.
- *
- * Returns: a new #SoupMessageBody.
- **/
 SoupMessageBody *
 soup_message_body_new (void)
 {
@@ -388,24 +380,17 @@ soup_message_body_wrote_chunk (SoupMessageBody *body, GBytes *chunk)
 }
 
 static SoupMessageBody *
-soup_message_body_copy (SoupMessageBody *body)
+soup_message_body_ref (SoupMessageBody *body)
 {
         g_atomic_rc_box_acquire (body);
 
        return body;
 }
 
-/**
- * soup_message_body_free:
- * @body: a #SoupMessageBody
- *
- * Frees @body. You will not normally need to use this, as
- * #SoupMessage frees its associated message bodies automatically.
- **/
 void
-soup_message_body_free (SoupMessageBody *body)
+soup_message_body_unref (SoupMessageBody *body)
 {
         g_atomic_rc_box_release_full (body, (GDestroyNotify)soup_message_body_truncate);
 }
 
-G_DEFINE_BOXED_TYPE (SoupMessageBody, soup_message_body, soup_message_body_copy, soup_message_body_free)
+G_DEFINE_BOXED_TYPE (SoupMessageBody, soup_message_body, soup_message_body_ref, soup_message_body_unref)
diff --git a/libsoup/server/soup-message-body.h b/libsoup/server/soup-message-body.h
index 5894f0bd..1347bbd3 100644
--- a/libsoup/server/soup-message-body.h
+++ b/libsoup/server/soup-message-body.h
@@ -24,9 +24,6 @@ SOUP_AVAILABLE_IN_ALL
 GType soup_message_body_get_type (void);
 #define SOUP_TYPE_MESSAGE_BODY (soup_message_body_get_type ())
 
-SOUP_AVAILABLE_IN_ALL
-SoupMessageBody *soup_message_body_new           (void);
-
 SOUP_AVAILABLE_IN_ALL
 void             soup_message_body_set_accumulate(SoupMessageBody *body,
                                                  gboolean         accumulate);
@@ -64,9 +61,4 @@ SOUP_AVAILABLE_IN_ALL
 void             soup_message_body_wrote_chunk   (SoupMessageBody *body,
                                                  GBytes          *chunk);
 
-SOUP_AVAILABLE_IN_ALL
-void             soup_message_body_free          (SoupMessageBody *body);
-
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (SoupMessageBody, soup_message_body_free)
-
 G_END_DECLS
diff --git a/libsoup/server/soup-server-message.c b/libsoup/server/soup-server-message.c
index 40f92c7e..89a0f93f 100644
--- a/libsoup/server/soup-server-message.c
+++ b/libsoup/server/soup-server-message.c
@@ -14,6 +14,7 @@
 #include "soup.h"
 #include "soup-connection.h"
 #include "soup-server-message-private.h"
+#include "soup-message-body-private.h"
 #include "soup-socket.h"
 #include "soup-uri-utils-private.h"
 
@@ -130,9 +131,9 @@ soup_server_message_finalize (GObject *object)
         g_clear_pointer (&msg->uri, g_uri_unref);
         g_free (msg->reason_phrase);
 
-        soup_message_body_free (msg->request_body);
+        soup_message_body_unref (msg->request_body);
         soup_message_headers_free (msg->request_headers);
-        soup_message_body_free (msg->response_body);
+        soup_message_body_unref (msg->response_body);
         soup_message_headers_free (msg->response_headers);
 
         G_OBJECT_CLASS (soup_server_message_parent_class)->finalize (object);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]