summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan McIntosh <ian_mcintosh@linuxadvocate.org>2005-10-25 21:52:08 +0000
committerIan McIntosh <ian_mcintosh@linuxadvocate.org>2005-10-25 21:52:08 +0000
commit1c7863052b7db8619e30c393802a6bd3db766ad1 (patch)
tree790c5edcfebea56a8e5decf33c28687722b770d5
parentd971066bbc5c89759b5d93eeda1214e836cb7ce9 (diff)
Switch from gfreelist to g_new and g_free for the list of selected POI
(currently not really used). Removed.
-rw-r--r--ChangeLog6
-rw-r--r--src/Makefile.am1
-rw-r--r--src/gfreelist.c145
-rw-r--r--src/gfreelist.h122
-rw-r--r--src/map.c4
-rw-r--r--src/map.h2
6 files changed, 7 insertions, 273 deletions
diff --git a/ChangeLog b/ChangeLog
index cd9b393..9ea6cf2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-10-25 Ian McIntosh <ian_mcintosh@linuxadvocate.org>
+
+ * src/map.c: Switch from gfreelist to g_new and g_free for the list of selected POI (currently not really used).
+ * src/gfreelist.h:
+ * src/gfreelist.c: Removed.
+
2005-10-20 Ian McIntosh <ian_mcintosh@linuxadvocate.org>
* roadster.spec: Added RPM .spec file contributed by Ofer Achler.
diff --git a/src/Makefile.am b/src/Makefile.am
index a7e1ec6..9277bf9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -52,7 +52,6 @@ roadster_SOURCES = \
glyph.c\
road.c\
animator.c\
- gfreelist.c\
tooltipwindow.c\
test_poly.c
diff --git a/src/gfreelist.c b/src/gfreelist.c
deleted file mode 100644
index e86b260..0000000
--- a/src/gfreelist.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- *
- * Copyright (C) 2003 Soeren Sandmann (sandmann@daimi.au.dk)
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#define G_IMPLEMENT_INLINES 1
-#define __G_FREELIST_C__
-
-#include "gfreelist.h"
-
-#include <glib.h>
-
-struct _GFreeListBlock
-{
- GFreeListBlock *next;
- gint8 *data;
-};
-
-GFreeList *
-g_free_list_new (gsize atom_size,
- gint n_prealloc)
-{
- GFreeList *list;
-
- g_return_val_if_fail (atom_size > 0, NULL);
- g_return_val_if_fail (n_prealloc > 0, NULL);
-
- list = g_new0 (GFreeList, 1);
-
- list->allocated = TRUE;
- list->atom_size = MAX (atom_size, sizeof (GFreeListAtom));
- list->n_prealloc = n_prealloc;
- list->atoms = NULL;
- list->blocks = NULL;
-
- return list;
-}
-
-static void
-g_free_list_ensure_atoms (GFreeList *list)
-{
- if (!list->atoms)
- {
- gint i;
-#ifdef DISABLE_MEM_POOLS
- const int n_atoms = 1;
-#else
- const int n_atoms = list->n_prealloc;
-#endif
-
- GFreeListBlock *block = g_new (GFreeListBlock, 1);
- block->data = g_malloc (list->atom_size * n_atoms);
- block->next = list->blocks;
- list->blocks = block;
-
- for (i = n_atoms - 1; i >= 0; --i)
- {
- GFreeListAtom *atom =
- (GFreeListAtom *)(block->data + i * list->atom_size);
-
- atom->next = list->atoms;
- list->atoms = atom;
- }
- }
-}
-
-gpointer
-g_free_list_alloc_internal (GFreeList *list)
-{
- gpointer result;
-
- g_return_val_if_fail (list != NULL, NULL);
-
- if (!list->atoms)
- g_free_list_ensure_atoms (list);
-
- result = list->atoms;
- list->atoms = list->atoms->next;
-
- return result;
-}
-
-void
-g_free_list_free_internal (GFreeList *list,
- gpointer mem)
-{
- GFreeListAtom *atom;
-
- g_return_if_fail (list != NULL);
-
- if (!mem)
- return;
-
- atom = mem;
-
- atom->next = list->atoms;
- list->atoms = atom;
-}
-
-static void
-g_free_list_free_all (GFreeList *list)
-{
- GFreeListBlock *block;
-
- g_return_if_fail (list != NULL);
-
- block = list->blocks;
- while (block)
- {
- GFreeListBlock *next = block->next;
-
- g_free (block->data);
- g_free (block);
-
- block = next;
- }
-
- list->atoms = NULL;
- list->blocks = NULL;
-}
-
-void
-g_free_list_destroy (GFreeList *list)
-{
- g_return_if_fail (list != NULL);
- g_return_if_fail (list->allocated);
-
- g_free_list_free_all (list);
- g_free (list);
-}
diff --git a/src/gfreelist.h b/src/gfreelist.h
deleted file mode 100644
index 16073d2..0000000
--- a/src/gfreelist.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- *
- * Copyright (C) 2003 Soeren Sandmann (sandmann@daimi.au.dk)
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __G_FREELIST_H__
-#define __G_FREELIST_H__
-
-#include <glib/gtypes.h>
-#include <glib/gutils.h>
-
-G_BEGIN_DECLS
-
-typedef struct _GFreeList GFreeList;
-typedef struct _GFreeListAtom GFreeListAtom;
-typedef struct _GFreeListBlock GFreeListBlock;
-
-struct _GFreeListAtom
-{
- GFreeListAtom *next;
-};
-
-struct _GFreeList
-{
- /*< private >*/
- gboolean allocated;
- gsize atom_size;
- gint n_prealloc;
- GFreeListAtom * atoms;
- GFreeListBlock * blocks;
-};
-
-#define G_FREE_LIST_NAME(name) \
- g__ ## name ## __free_list
-
-#define G_FREE_LIST_EXTERN(name) \
- extern GFreeList G_FREE_LIST_NAME (name)
-
-/* Defining free lists */
-#define G_FREE_LIST_DEFINE(name, atom_size, n_prealloc) \
- GFreeList G_FREE_LIST_NAME (name) = \
- { \
- FALSE, /* allocated */ \
- MAX (atom_size, sizeof (GFreeListAtom)), /* atom_size */ \
- n_prealloc, /* n_prealloc */ \
- NULL, /* atoms */ \
- NULL /* blocks */ \
- }
-
-#define G_FREE_LIST_DEFINE_STATIC(name, atom_size, n_prealloc) \
- static G_FREE_LIST_DEFINE (name, atom_size, n_prealloc)
-
-/* Macros to allocate and free atoms */
-#define G_FREE_LIST_ALLOC(name) \
- g_free_list_alloc (&G_FREE_LIST_NAME (name))
-
-#define G_FREE_LIST_FREE(name, mem) \
- g_free_list_free (&G_FREE_LIST_NAME (name), mem)
-
-
-/* functions */
-GFreeList * g_free_list_new (gsize atom_size,
- gint n_prealloc);
-void g_free_list_destroy (GFreeList *free_list);
-
-G_INLINE_FUNC
-gpointer g_free_list_alloc (GFreeList *list);
-
-G_INLINE_FUNC
-void g_free_list_free (GFreeList *list,
- gpointer mem);
-
-/* internal functions */
-gpointer g_free_list_alloc_internal (GFreeList *flist);
-void g_free_list_free_internal (GFreeList *flist,
- gpointer mem);
-
-/* inline functions */
-
-#if defined (G_CAN_INLINE) || defined (__G_FREELIST_C__)
-
-G_INLINE_FUNC gpointer
-g_free_list_alloc (GFreeList *flist)
-{
- GFreeListAtom *result = flist->atoms;
-
- if (G_LIKELY (result))
- flist->atoms = result->next;
- else
- result = g_free_list_alloc_internal (flist);
-
- return result;
-}
-
-G_INLINE_FUNC void
-g_free_list_free (GFreeList *flist,
- gpointer mem)
-{
- ((GFreeListAtom *)mem)->next = flist->atoms;
- flist->atoms = mem;
-}
-
-#endif /* G_CAN_INLINE || __G_FREELIST_C__ */
-
-G_END_DECLS
-
-#endif /* __G_FREELIST_H__ */
diff --git a/src/map.c b/src/map.c
index 4eb123a..9183875 100644
--- a/src/map.c
+++ b/src/map.c
@@ -195,7 +195,6 @@ gboolean map_new(map_t** ppMap, GtkWidget* pTargetWidget)
// init POI selection
pMap->pLocationSelectionArray = g_ptr_array_new();
- pMap->pLocationSelectionAllocator = g_free_list_new(sizeof(locationselection_t), 100);
// save it
*ppMap = pMap;
@@ -563,8 +562,7 @@ gboolean map_location_selection_add(map_t* pMap, gint nLocationID)
}
// create a new locationselection_t and initialize it
- locationselection_t* pNew = g_free_list_alloc(pMap->pLocationSelectionAllocator);
-
+ locationselection_t* pNew = g_new0(locationselection_t, 1);
pNew->nLocationID = nLocationID;
pNew->pAttributesArray = g_ptr_array_new();
diff --git a/src/map.h b/src/map.h
index 3997e6d..7aa2785 100644
--- a/src/map.h
+++ b/src/map.h
@@ -25,7 +25,6 @@
#define _MAP_H_
#include <math.h>
-#include "gfreelist.h"
//
// Map Object Types
@@ -220,7 +219,6 @@ typedef struct {
GHashTable *pLocationArrayHashTable;
GPtrArray *pLocationSelectionArray;
- GFreeList *pLocationSelectionAllocator;
GdkPixmap* pPixmap;