[maemo-commits] [maemo-commits] r17069 - in projects/haf/trunk/sapwood: . server

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Fri Jan 9 15:45:53 EET 2009
Author: herzi
Date: 2009-01-09 15:45:50 +0200 (Fri, 09 Jan 2009)
New Revision: 17069

Added:
   projects/haf/trunk/sapwood/server/cache-node.c
   projects/haf/trunk/sapwood/server/cache-node.h
Modified:
   projects/haf/trunk/sapwood/ChangeLog
   projects/haf/trunk/sapwood/server/Makefile.am
   projects/haf/trunk/sapwood/server/sapwood-server.c
Log:
2008-09-08  Sven Herzberg  <sven at imendio.com>

	Moved memory management for CacheNode into separate files; now we have
	two well-specified locations left for allocation and free of CacheNode

	* server/Makefile.am: build the new files, too
	* server/cache-node.c (cache_node_free), (cache_node_new): added new
	functions
	* server/cache-node.h: have the structure definition here; added
	declarations of the new functions
	* server/sapwood-server.c (process_buffer),
	(cleanup_pixmap_destroy): replace the code to create/free an object
	with proper function calls


Modified: projects/haf/trunk/sapwood/ChangeLog
===================================================================
--- projects/haf/trunk/sapwood/ChangeLog	2009-01-09 12:20:10 UTC (rev 17068)
+++ projects/haf/trunk/sapwood/ChangeLog	2009-01-09 13:45:50 UTC (rev 17069)
@@ -1,3 +1,17 @@
+2008-09-08  Sven Herzberg  <sven at imendio.com>
+
+	Moved memory management for CacheNode into separate files; now we have
+	two well-specified locations left for allocation and free of CacheNode
+
+	* server/Makefile.am: build the new files, too
+	* server/cache-node.c (cache_node_free), (cache_node_new): added new
+	functions
+	* server/cache-node.h: have the structure definition here; added
+	declarations of the new functions
+	* server/sapwood-server.c (process_buffer),
+	(cleanup_pixmap_destroy): replace the code to create/free an object
+	with proper function calls
+
 2008-11-27  Sven Herzberg  <sven at imendio.com>
 
 	Properly follow common memory management logic

Modified: projects/haf/trunk/sapwood/server/Makefile.am
===================================================================
--- projects/haf/trunk/sapwood/server/Makefile.am	2009-01-09 12:20:10 UTC (rev 17068)
+++ projects/haf/trunk/sapwood/server/Makefile.am	2009-01-09 13:45:50 UTC (rev 17069)
@@ -8,7 +8,10 @@
 daemondir = $(libdir)/sapwood
 daemon_PROGRAMS = sapwood-server
 
-sapwood_server_SOURCES = sapwood-server.c
+sapwood_server_SOURCES = \
+	cache-node.c \
+	cache-node.h \
+	sapwood-server.c
 sapwood_server_LDADD = $(GDK_LIBS) ../protocol/libprotocol.la
 sapwood_server_CFLAGS = $(AM_CFLAGS)	# created both with libtool and without
 

Added: projects/haf/trunk/sapwood/server/cache-node.c
===================================================================
--- projects/haf/trunk/sapwood/server/cache-node.c	2009-01-09 12:20:10 UTC (rev 17068)
+++ projects/haf/trunk/sapwood/server/cache-node.c	2009-01-09 13:45:50 UTC (rev 17069)
@@ -0,0 +1,43 @@
+/* This file is part of the GTK+ Sapwood Engine
+ *
+ * AUTHORS
+ *     Tommi Komulainen
+ *     Sven Herzberg
+ *
+ * Copyright (C) 2005  Nokia Corporation
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+#include "config.h"
+
+#include "cache-node.h"
+
+void
+cache_node_free (CacheNode* self)
+{
+  g_free (self);
+}
+
+CacheNode*
+cache_node_new (PixbufOpenResponse* rep)
+{
+  CacheNode* self = g_new0 (CacheNode, 1);
+  self->rep = rep;
+  self->refcnt = 1;
+  return self;
+}
+

Added: projects/haf/trunk/sapwood/server/cache-node.h
===================================================================
--- projects/haf/trunk/sapwood/server/cache-node.h	2009-01-09 12:20:10 UTC (rev 17068)
+++ projects/haf/trunk/sapwood/server/cache-node.h	2009-01-09 13:45:50 UTC (rev 17069)
@@ -0,0 +1,44 @@
+/* This file is part of the GTK+ Sapwood Engine
+ *
+ * AUTHORS
+ *     Tommi Komulainen
+ *     Sven Herzberg
+ *
+ * Copyright (C) 2005  Nokia Corporation
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+#ifndef CACHE_NODE_H
+#define CACHE_NODE_H
+
+#include "sapwood-proto.h"
+
+G_BEGIN_DECLS
+
+typedef struct _CacheNode CacheNode;
+
+CacheNode* cache_node_new  (PixbufOpenResponse *rep);
+void       cache_node_free (CacheNode          *self);
+
+struct _CacheNode {
+  PixbufOpenResponse *rep;
+  guint               refcnt;
+};
+
+G_END_DECLS
+
+#endif /* !CACHE_NODE_H */

Modified: projects/haf/trunk/sapwood/server/sapwood-server.c
===================================================================
--- projects/haf/trunk/sapwood/server/sapwood-server.c	2009-01-09 12:20:10 UTC (rev 17068)
+++ projects/haf/trunk/sapwood/server/sapwood-server.c	2009-01-09 13:45:50 UTC (rev 17069)
@@ -20,7 +20,7 @@
  */
 #include <config.h>
 
-#include "sapwood-proto.h"
+#include "cache-node.h"
 
 #include <gdk/gdk.h>
 #include <gdk/gdkx.h>
@@ -53,11 +53,6 @@
 
 static const char *sock_path;
 
-typedef struct {
-  PixbufOpenResponse *rep;
-  guint               refcnt;
-} CacheNode;
-
 #ifndef HAVE_ABSTRACT_SOCKETS
 static void
 atexit_handler (void)
@@ -365,12 +360,7 @@
 
 	  node = g_hash_table_lookup (cleanup, GUINT_TO_POINTER(rep->id));
 	  if (!node)
-	    {
-	      node = g_new(CacheNode, 1);
-	      node->rep = rep;
-	      node->refcnt = 1;
-	      g_hash_table_insert (cleanup, GUINT_TO_POINTER(rep->id), node);
-	    }
+            g_hash_table_insert (cleanup, GUINT_TO_POINTER(rep->id), cache_node_new (rep));
 	  else
 	    node->refcnt++;
 
@@ -496,7 +486,7 @@
 {
   CacheNode *node = data;
   g_cache_remove (pixmap_cache, node->rep);
-  g_free (node);
+  cache_node_free (node);
 }
 
 static gboolean


More information about the maemo-commits mailing list