Memchunks are deprecated, and perform poorly.  GLib replaced
them with the slice allocator.

This allows roadster to compile without --enable-deprecated.

Signed-off-by: Jeff Garrett <[EMAIL PROTECTED]>
---
 src/location.c    |   10 ++--------
 src/locationset.c |   13 ++-----------
 2 files changed, 4 insertions(+), 19 deletions(-)

diff --git a/src/location.c b/src/location.c
index fa21d2a..9f19c16 100644
--- a/src/location.c
+++ b/src/location.c
@@ -31,14 +31,10 @@
 gboolean location_lookup_attribute_name(const gchar* pszName, gint* 
pnReturnID);
 
 struct {
-       GMemChunk* pLocationChunkAllocator;
 } g_Location;
 
 void location_init()
 {
-       g_Location.pLocationChunkAllocator = g_mem_chunk_new("ROADSTER 
locations",
-                       sizeof(location_t), sizeof(location_t) * 1000, 
G_ALLOC_AND_FREE);
-       g_return_if_fail(g_Location.pLocationChunkAllocator != NULL);
 }
 
 // get a new point struct from the allocator
@@ -46,9 +42,8 @@ gboolean location_alloc(location_t** ppLocation)
 {
        g_return_val_if_fail(ppLocation != NULL, FALSE);
        g_return_val_if_fail(*ppLocation == NULL, FALSE);       // must be a 
pointer to a NULL pointer
-       g_return_val_if_fail(g_Location.pLocationChunkAllocator != NULL, FALSE);
 
-       location_t* pNew = 
g_mem_chunk_alloc0(g_Location.pLocationChunkAllocator);
+       location_t* pNew = g_slice_new0(location_t);
        if(pNew) {
                *ppLocation = pNew;
                return TRUE;
@@ -60,12 +55,11 @@ gboolean location_alloc(location_t** ppLocation)
 void location_free(location_t* pLocation)
 {
        g_return_if_fail(pLocation != NULL);
-       g_return_if_fail(g_Location.pLocationChunkAllocator != NULL);
 
        g_free(pLocation->pszName);
 
        // give back to allocator
-       g_mem_chunk_free(g_Location.pLocationChunkAllocator, pLocation);
+       g_slice_free(location_t, pLocation);
 }
 
 gboolean location_insert(gint nLocationSetID, mappoint_t* pPoint, gint* 
pnReturnID)
diff --git a/src/locationset.c b/src/locationset.c
index 7e26070..3f058b7 100644
--- a/src/locationset.c
+++ b/src/locationset.c
@@ -37,27 +37,18 @@
 struct {
        GPtrArray* pLocationSetArray;   // an array of locationsets
        GHashTable* pLocationSetHash;   // stores pointers to locationsets, 
indexed by ID
-
-       GMemChunk* pLocationSetChunkAllocator;  // allocs locationset_t objects
 } g_LocationSet;
 
 void locationset_init()
 {
        g_LocationSet.pLocationSetArray = g_ptr_array_new();
        g_LocationSet.pLocationSetHash = g_hash_table_new(g_int_hash, 
g_int_equal);
-
-       // create memory allocator
-       g_LocationSet.pLocationSetChunkAllocator = g_mem_chunk_new("ROADSTER 
locationsets",
-                       sizeof(locationset_t), sizeof(locationset_t) * 20, 
G_ALLOC_AND_FREE);
-       g_return_if_fail(g_LocationSet.pLocationSetChunkAllocator != NULL);
 }
 
 // get a new locationset struct from the allocator
 static gboolean locationset_alloc(locationset_t** ppReturn)
 {
-       g_return_val_if_fail(g_LocationSet.pLocationSetChunkAllocator != NULL, 
FALSE);
-
-       locationset_t* pNew = 
g_mem_chunk_alloc0(g_LocationSet.pLocationSetChunkAllocator);
+       locationset_t* pNew = g_slice_new0(locationset_t);
 
        // set defaults
        pNew->bVisible = TRUE;
@@ -153,7 +144,7 @@ static void locationset_free(locationset_t* pLocationSet)
        locationset_clear(pLocationSet);
 
        // give back to allocator
-       g_mem_chunk_free(g_LocationSet.pLocationSetChunkAllocator, 
pLocationSet);
+       g_slice_free(locationset_t, pLocationSet);
 }
 
 static void locationset_clear_all_locations(void)
-- 
1.4.4.2

_______________________________________________
roadster mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/roadster

Reply via email to