* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
+ * 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
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Library General Public
+ * 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.
*/
/*
- * Modified by the GLib Team and others 1997-1999. See the AUTHORS
+ * Modified by the GLib Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GLib Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GLib at ftp://ftp.gtk.org/pub/gtk/.
#ifdef ENABLE_MEM_CHECK
t = (gulong*) ((guchar*) mem - SIZEOF_LONG);
if (*t >= 1)
- g_warning ("freeing previously freed memory\n");
+ g_warning ("freeing previously freed (%lu times) memory\n", *t);
*t += 1;
mem = t;
- memset ((guchar*) mem + 8, 0, size);
+ memset ((guchar*) mem + 2 * SIZEOF_LONG, 0, size);
#else /* ENABLE_MEM_CHECK */
free (mem);
#endif /* ENABLE_MEM_CHECK */
t = (gulong*) ((guchar*) mem - SIZEOF_LONG - SIZEOF_LONG);
if (*t >= 1)
- g_warning ("mem: 0x%08x has been freed %lu times\n", (gulong) mem, *t);
+ g_warning ("mem: 0x%08lx has been freed %lu times\n", (gulong) mem, *t);
#endif /* ENABLE_MEM_CHECK */
}
/* Determine which area this piece of memory is allocated from */
temp_area = g_tree_search (rmem_chunk->mem_tree,
- (GSearchFunc) g_mem_chunk_area_search,
+ (GCompareFunc) g_mem_chunk_area_search,
mem);
/* If the area has been marked, then it is being destroyed.
}
else
{
+#ifdef ENABLE_GC_FRIENDLY
+ rmem_chunk->mem_area = (GMemArea*) g_malloc0 (sizeof (GMemArea) -
+ MEM_AREA_SIZE +
+ rmem_chunk->area_size);
+#else /* !ENABLE_GC_FRIENDLY */
rmem_chunk->mem_area = (GMemArea*) g_malloc (sizeof (GMemArea) -
MEM_AREA_SIZE +
rmem_chunk->area_size);
+#endif /* ENABLE_GC_FRIENDLY */
rmem_chunk->num_mem_areas += 1;
rmem_chunk->mem_area->next = rmem_chunk->mem_areas;
rmem_chunk = (GRealMemChunk*) mem_chunk;
+#ifdef ENABLE_GC_FRIENDLY
+ memset (mem, 0, rmem_chunk->atom_size);
+#endif /* ENABLE_GC_FRIENDLY */
+
/* Don't do anything if this is an ALLOC_ONLY chunk
*/
if (rmem_chunk->type == G_ALLOC_AND_FREE)
rmem_chunk->free_atoms = free_atom;
temp_area = g_tree_search (rmem_chunk->mem_tree,
- (GSearchFunc) g_mem_chunk_area_search,
+ (GCompareFunc) g_mem_chunk_area_search,
mem);
temp_area->allocated -= 1;
mem = (gpointer) temp_free_atom;
mem_area = g_tree_search (rmem_chunk->mem_tree,
- (GSearchFunc) g_mem_chunk_area_search,
+ (GCompareFunc) g_mem_chunk_area_search,
mem);
/* If this mem area is marked for destruction then delete the