[kdbus] sync with kdbus (kdbus.h - commit: 5ae1ecac44cb)
[platform/upstream/glib.git] / tests / memchunks.c
index 7a08de0..d2c4811 100644 (file)
@@ -12,9 +12,7 @@
  * 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.
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
 /*
@@ -50,7 +48,6 @@ static guint mem_chunk_recursion = 0;
 #  define LEAVE_MEM_CHUNK_ROUTINE()    (mem_chunk_recursion = MEM_CHUNK_ROUTINE_COUNT () - 1)
 
 /* --- old memchunk prototypes --- */
-void            old_mem_chunks_init     (void);
 GMemChunk*      old_mem_chunk_new       (const gchar  *name,
                                          gint          atom_size,
                                          gulong        area_size,
@@ -127,15 +124,9 @@ static gint   old_mem_chunk_area_search  (GMemArea *a,
 /* here we can't use StaticMutexes, as they depend upon a working
  * g_malloc, the same holds true for StaticPrivate
  */
-static GMutex        *mem_chunks_lock = NULL;
+static GMutex         mem_chunks_lock;
 static GMemChunk     *mem_chunks = NULL;
 
-void
-old_mem_chunks_init (void)
-{
-  mem_chunks_lock = g_mutex_new ();
-}
-
 GMemChunk*
 old_mem_chunk_new (const gchar  *name,
                    gint          atom_size,
@@ -175,13 +166,13 @@ old_mem_chunk_new (const gchar  *name,
   rarea_size = old_mem_chunk_compute_size (rarea_size, atom_size + sizeof (GMemArea) - MEM_AREA_SIZE);
   mem_chunk->area_size = rarea_size - (sizeof (GMemArea) - MEM_AREA_SIZE);
   
-  g_mutex_lock (mem_chunks_lock);
+  g_mutex_lock (&mem_chunks_lock);
   mem_chunk->next = mem_chunks;
   mem_chunk->prev = NULL;
   if (mem_chunks)
     mem_chunks->prev = mem_chunk;
   mem_chunks = mem_chunk;
-  g_mutex_unlock (mem_chunks_lock);
+  g_mutex_unlock (&mem_chunks_lock);
   
   LEAVE_MEM_CHUNK_ROUTINE ();
   
@@ -206,7 +197,7 @@ old_mem_chunk_destroy (GMemChunk *mem_chunk)
       g_free (temp_area);
     }
   
-  g_mutex_lock (mem_chunks_lock);
+  g_mutex_lock (&mem_chunks_lock);
   if (mem_chunk->next)
     mem_chunk->next->prev = mem_chunk->prev;
   if (mem_chunk->prev)
@@ -214,7 +205,7 @@ old_mem_chunk_destroy (GMemChunk *mem_chunk)
   
   if (mem_chunk == mem_chunks)
     mem_chunks = mem_chunks->next;
-  g_mutex_unlock (mem_chunks_lock);
+  g_mutex_unlock (&mem_chunks_lock);
   
   if (mem_chunk->type == G_ALLOC_AND_FREE)
     g_tree_destroy (mem_chunk->mem_tree);  
@@ -253,7 +244,7 @@ old_mem_chunk_alloc (GMemChunk *mem_chunk)
        *  (ie marked to be destroyed).
        * We check to see if all of the segments on the free list that
        *  reference this area have been removed. This occurs when
-       *  the ammount of free memory is less than the allocatable size.
+       *  the amount of free memory is less than the allocatable size.
        * If the chunk should be freed, then we place it in the "free_mem_area".
        * This is so we make sure not to free the mem area here and then
        *  allocate it again a few lines down.
@@ -545,20 +536,20 @@ old_mem_chunk_info (void)
   gint count;
   
   count = 0;
-  g_mutex_lock (mem_chunks_lock);
+  g_mutex_lock (&mem_chunks_lock);
   mem_chunk = mem_chunks;
   while (mem_chunk)
     {
       count += 1;
       mem_chunk = mem_chunk->next;
     }
-  g_mutex_unlock (mem_chunks_lock);
+  g_mutex_unlock (&mem_chunks_lock);
   
   g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "%d mem chunks", count);
   
-  g_mutex_lock (mem_chunks_lock);
+  g_mutex_lock (&mem_chunks_lock);
   mem_chunk = mem_chunks;
-  g_mutex_unlock (mem_chunks_lock);
+  g_mutex_unlock (&mem_chunks_lock);
   
   while (mem_chunk)
     {