[Spice-commits] 2 commits - server/tests

Frediano Ziglio fziglio at kemper.freedesktop.org
Tue Dec 15 09:40:40 PST 2015


 server/tests/Makefile.am        |    4 +---
 server/tests/basic_event_loop.c |    9 +++++----
 2 files changed, 6 insertions(+), 7 deletions(-)

New commits:
commit b953a4e35f185dd5c9225ea3d1e8ff1813b9d16e
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Tue Dec 15 10:42:33 2015 +0000

    tests: reuse Makefile macro
    
    For coherency use COMMON_BASE macro instead of including single
    files.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/server/tests/Makefile.am b/server/tests/Makefile.am
index fd7e26d..d0bd5a0 100644
--- a/server/tests/Makefile.am
+++ b/server/tests/Makefile.am
@@ -121,11 +121,9 @@ test_display_width_stride_SOURCES =		\
 	$(NULL)
 
 spice_server_replay_SOURCES = 			\
+	$(COMMON_BASE)				\
 	replay.c				\
 	test_display_base.h			\
-	basic_event_loop.c			\
-	basic_event_loop.h			\
-	test_util.h				\
 	$(NULL)
 
 stat_test_SOURCES = stat-main.c
commit 276d9f08cd9c7cde65cc17c077aae68d5e366554
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Tue Dec 15 10:49:35 2015 +0000

    tests: allocate memory in a coherent fashion
    
    Do not free memory allocated with C functions (like calloc) using g_free;
    although this is possible with default Glib allocator this is not safe.
    Also use consistent allocation functions. All other spice-server code
    does not use Glib allocations so for coherence do not use them for
    watches.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/server/tests/basic_event_loop.c b/server/tests/basic_event_loop.c
index 85b4da4..c9c2637 100644
--- a/server/tests/basic_event_loop.c
+++ b/server/tests/basic_event_loop.c
@@ -25,6 +25,7 @@
 
 #include "spice/macros.h"
 #include "common/ring.h"
+#include "common/mem.h"
 #include "test_util.h"
 #include "basic_event_loop.h"
 
@@ -47,7 +48,7 @@ struct SpiceTimer {
 
 static SpiceTimer* timer_add(SpiceTimerFunc func, void *opaque)
 {
-    SpiceTimer *timer = calloc(sizeof(SpiceTimer), 1);
+    SpiceTimer *timer = spice_malloc0(sizeof(SpiceTimer));
 
     timer->func = func;
     timer->opaque = opaque;
@@ -85,7 +86,7 @@ static void timer_start(SpiceTimer *timer, uint32_t ms)
 static void timer_remove(SpiceTimer *timer)
 {
     timer_cancel(timer);
-    g_free(timer);
+    free(timer);
 }
 
 struct SpiceWatch {
@@ -135,7 +136,7 @@ static SpiceWatch *watch_add(int fd, int event_mask, SpiceWatchFunc func, void *
     SpiceWatch *watch;
     GIOCondition condition = spice_event_to_condition(event_mask);
 
-    watch = g_new(SpiceWatch, 1);
+    watch = spice_malloc0(sizeof(SpiceWatch));
     watch->channel = g_io_channel_unix_new(fd);
     watch->source_id = g_io_add_watch(watch->channel, condition, watch_func, watch);
     watch->func = func;
@@ -157,7 +158,7 @@ static void watch_remove(SpiceWatch *watch)
 {
     g_source_remove(watch->source_id);
     g_io_channel_unref(watch->channel);
-    g_free(watch);
+    free(watch);
 }
 
 static void channel_event(int event, SpiceChannelEventInfo *info)


More information about the Spice-commits mailing list