reflect renaming of g_string_sprintfa to g_string_printfa
[platform/upstream/glib.git] / gmem.c
diff --git a/gmem.c b/gmem.c
index bcdc7fc..616614b 100644 (file)
--- a/gmem.c
+++ b/gmem.c
@@ -101,7 +101,7 @@ standard_realloc (gpointer mem,
 static void
 standard_free (gpointer mem)
 {
-  return free (mem);
+  free (mem);
 }
 static gpointer
 standard_calloc (gsize n_blocks,
@@ -268,9 +268,9 @@ static gulong profile_frees = 0;
 static gulong profile_mc_frees = 0;
 static GMutex *g_profile_mutex = NULL;
 #ifdef  G_ENABLE_DEBUG
-static volatile gulong glib_trap_free_size = 0;
-static volatile gulong glib_trap_realloc_size = 0;
-static volatile gulong glib_trap_malloc_size = 0;
+static volatile gulong g_trap_free_size = 0;
+static volatile gulong g_trap_realloc_size = 0;
+static volatile gulong g_trap_malloc_size = 0;
 #endif  /* G_ENABLE_DEBUG */
 
 #define        PROFILE_TABLE(f1,f2,f3)   ( ( ((f3) << 2) | ((f2) << 1) | (f1) ) * (MEM_PROFILE_TABLE_SIZE + 1))
@@ -363,22 +363,31 @@ void
 g_mem_profile (void)
 {
   guint local_data[(MEM_PROFILE_TABLE_SIZE + 1) * 8 * sizeof (profile_data[0])];
-  gulong local_allocs = profile_allocs;
-  gulong local_zinit = profile_zinit;
-  gulong local_frees = profile_frees;
-  gulong local_mc_allocs = profile_mc_allocs;
-  gulong local_mc_frees = profile_mc_frees;
+  gulong local_allocs;
+  gulong local_zinit;
+  gulong local_frees;
+  gulong local_mc_allocs;
+  gulong local_mc_frees;
 
   g_mutex_lock (g_profile_mutex);
 
+  local_allocs = profile_allocs;
+  local_zinit = profile_zinit;
+  local_frees = profile_frees;
+  local_mc_allocs = profile_mc_allocs;
+  local_mc_frees = profile_mc_frees;
+
   if (!profile_data)
     {
       g_mutex_unlock (g_profile_mutex);
       return;
     }
 
-  memcpy (local_data, profile_data, (MEM_PROFILE_TABLE_SIZE + 1) * 8 * sizeof (profile_data[0]));
+  memcpy (local_data, profile_data, 
+         (MEM_PROFILE_TABLE_SIZE + 1) * 8 * sizeof (profile_data[0]));
   
+  g_mutex_unlock (g_profile_mutex);
+
   g_print ("GLib Memory statistics (successful operations):\n");
   profile_print_locked (local_data, TRUE);
   g_print ("GLib Memory statistics (failing operations):\n");
@@ -395,7 +404,6 @@ g_mem_profile (void)
           local_mc_frees,
           ((gdouble) local_mc_frees) / local_mc_allocs * 100.0,
           local_mc_allocs - local_mc_frees);
-  g_mutex_unlock (g_profile_mutex);
 }
 
 static gpointer
@@ -404,7 +412,7 @@ profiler_try_malloc (gsize n_bytes)
   gulong *p;
 
 #ifdef  G_ENABLE_DEBUG
-  if (glib_trap_malloc_size == n_bytes)
+  if (g_trap_malloc_size == n_bytes)
     G_BREAKPOINT ();
 #endif  /* G_ENABLE_DEBUG */
 
@@ -442,7 +450,7 @@ profiler_calloc (gsize n_blocks,
   gulong *p;
 
 #ifdef  G_ENABLE_DEBUG
-  if (glib_trap_malloc_size == l)
+  if (g_trap_malloc_size == l)
     G_BREAKPOINT ();
 #endif  /* G_ENABLE_DEBUG */
   
@@ -480,7 +488,7 @@ profiler_free (gpointer mem)
   else
     {
 #ifdef  G_ENABLE_DEBUG
-      if (glib_trap_free_size == p[1])
+      if (g_trap_free_size == p[1])
        G_BREAKPOINT ();
 #endif  /* G_ENABLE_DEBUG */
 
@@ -506,7 +514,7 @@ profiler_try_realloc (gpointer mem,
   p -= 2;
 
 #ifdef  G_ENABLE_DEBUG
-  if (glib_trap_realloc_size == n_bytes)
+  if (g_trap_realloc_size == n_bytes)
     G_BREAKPOINT ();
 #endif  /* G_ENABLE_DEBUG */
   
@@ -591,7 +599,7 @@ struct _GMemArea
 
 struct _GRealMemChunk
 {
-  gchar *name;               /* name of this MemChunk...used for debugging output */
+  const gchar *name;         /* name of this MemChunk...used for debugging output */
   gint type;                 /* the type of MemChunk: ALLOC_ONLY or ALLOC_AND_FREE */
   gint num_mem_areas;        /* the number of memory areas */
   gint num_marked_areas;     /* the number of areas marked for deletion */
@@ -622,10 +630,10 @@ static GMutex        *mem_chunks_lock = NULL;
 static GRealMemChunk *mem_chunks = NULL;
 
 GMemChunk*
-g_mem_chunk_new (gchar  *name,
-                gint    atom_size,
-                gulong  area_size,
-                gint    type)
+g_mem_chunk_new (const gchar  *name,
+                gint          atom_size,
+                gulong        area_size,
+                gint          type)
 {
   GRealMemChunk *mem_chunk;
   gulong rarea_size;
@@ -705,8 +713,8 @@ g_mem_chunk_destroy (GMemChunk *mem_chunk)
   g_mutex_unlock (mem_chunks_lock);
   
   if (rmem_chunk->type == G_ALLOC_AND_FREE)
-    g_tree_destroy (rmem_chunk->mem_tree);
-  
+    g_tree_destroy (rmem_chunk->mem_tree);  
+
   g_free (rmem_chunk);
 
   LEAVE_MEM_CHUNK_ROUTINE ();
@@ -1135,10 +1143,10 @@ typedef struct {
 }  GMinimalMemChunk;
 
 GMemChunk*
-g_mem_chunk_new (gchar  *name,
-                gint    atom_size,
-                gulong  area_size,
-                gint    type)
+g_mem_chunk_new (const gchar  *name,
+                gint          atom_size,
+                gulong        area_size,
+                gint          type)
 {
   GMinimalMemChunk *mem_chunk;