[PATCH spice-server 04/11] reds: Start using GLib memory functions

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

 



Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/reds.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/server/reds.c b/server/reds.c
index 01e8c5499..3782e6404 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -2051,7 +2051,7 @@ static void reds_handle_ticket(void *opaque)
                       RSA_size(link->tiTicketing.rsa), SPICE_MAX_PASSWORD_LENGTH);
     }
 
-    password = spice_malloc0(RSA_size(link->tiTicketing.rsa) + 1);
+    password = g_new0(char, RSA_size(link->tiTicketing.rsa) + 1);
     password_size = RSA_private_decrypt(link->tiTicketing.rsa_size,
                                         link->tiTicketing.encrypted_ticket.encrypted_data,
                                         (unsigned char *)password,
@@ -2092,7 +2092,7 @@ error:
     reds_link_free(link);
 
 end:
-    free(password);
+    g_free(password);
 }
 
 static void reds_get_spice_ticket(RedLinkInfo *link)
@@ -3499,7 +3499,7 @@ static const char default_video_codecs[] = "spice:mjpeg;" GSTREAMER_CODECS;
 SPICE_GNUC_VISIBLE SpiceServer *spice_server_new(void)
 {
     const char *record_filename;
-    RedsState *reds = spice_new0(RedsState, 1);
+    RedsState *reds = g_new0(RedsState, 1);
 
     reds->config = spice_new0(RedServerConfig, 1);
     reds->config->default_channel_security =
@@ -3671,6 +3671,7 @@ static void reds_set_video_codecs_from_string(RedsState *reds, const char *codec
             g_array_append_val(video_codecs, new_codec);
         }
 
+        /* these are allocated by sscanf, do not use g_free */
         free(encoder_name);
         free(codec_name);
         codecs = c;
@@ -3709,9 +3710,9 @@ static void reds_config_free(RedServerConfig *config)
         free(curr);
     }
 #if HAVE_SASL
-    free(config->sasl_appname);
+    g_free(config->sasl_appname);
 #endif
-    free(config->spice_name);
+    g_free(config->spice_name);
     g_array_unref(config->renderers);
     g_array_unref(config->video_codecs);
     free(config);
@@ -3760,7 +3761,7 @@ SPICE_GNUC_VISIBLE void spice_server_destroy(SpiceServer *reds)
 #endif
 
     reds_config_free(reds->config);
-    free(reds);
+    g_free(reds);
 }
 
 SPICE_GNUC_VISIBLE spice_compat_version_t spice_get_current_compat_version(void)
@@ -3839,8 +3840,8 @@ SPICE_GNUC_VISIBLE int spice_server_set_sasl(SpiceServer *s, int enabled)
 SPICE_GNUC_VISIBLE int spice_server_set_sasl_appname(SpiceServer *s, const char *appname)
 {
 #if HAVE_SASL
-    free(s->config->sasl_appname);
-    s->config->sasl_appname = spice_strdup(appname);
+    g_free(s->config->sasl_appname);
+    s->config->sasl_appname = g_strdup(appname);
     return 0;
 #else
     return -1;
@@ -3849,8 +3850,8 @@ SPICE_GNUC_VISIBLE int spice_server_set_sasl_appname(SpiceServer *s, const char
 
 SPICE_GNUC_VISIBLE void spice_server_set_name(SpiceServer *s, const char *name)
 {
-    free(s->config->spice_name);
-    s->config->spice_name = spice_strdup(name);
+    g_free(s->config->spice_name);
+    s->config->spice_name = g_strdup(name);
 }
 
 SPICE_GNUC_VISIBLE void spice_server_set_uuid(SpiceServer *s, const uint8_t uuid[16])
-- 
2.13.5

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]