mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-23 10:42:11 +01:00
changed size argument type from gulong to gsize as discussed on
2008-01-29 14:58:31 Tim Janik <timj@imendio.com> * glib/gmem.[hc]: changed size argument type from gulong to gsize as discussed on gtk-devel-list: http://mail.gnome.org/archives/gtk-devel-list/2007-March/msg00062.html this should be ABI compatible on all platforms except win64 for which no ABI binding port exists yet. svn path=/trunk/; revision=6413
This commit is contained in:
parent
3b78d8000b
commit
1fcaf2fe8d
@ -1,3 +1,11 @@
|
|||||||
|
2008-01-29 14:58:31 Tim Janik <timj@imendio.com>
|
||||||
|
|
||||||
|
* glib/gmem.[hc]: changed size argument type from gulong to gsize as
|
||||||
|
discussed on gtk-devel-list:
|
||||||
|
http://mail.gnome.org/archives/gtk-devel-list/2007-March/msg00062.html
|
||||||
|
this should be ABI compatible on all platforms except win64 for which
|
||||||
|
no ABI binding port exists yet.
|
||||||
|
|
||||||
2008-01-29 Sebastian Wilhelmi <wilhelmi@google.com>
|
2008-01-29 Sebastian Wilhelmi <wilhelmi@google.com>
|
||||||
|
|
||||||
* tests/threadpool-test.c (test_thread_pools): Grab
|
* tests/threadpool-test.c (test_thread_pools): Grab
|
||||||
|
50
glib/gmem.c
50
glib/gmem.c
@ -120,7 +120,7 @@ static GMemVTable glib_mem_vtable = {
|
|||||||
|
|
||||||
/* --- functions --- */
|
/* --- functions --- */
|
||||||
gpointer
|
gpointer
|
||||||
g_malloc (gulong n_bytes)
|
g_malloc (gsize n_bytes)
|
||||||
{
|
{
|
||||||
if (G_UNLIKELY (!g_mem_initialized))
|
if (G_UNLIKELY (!g_mem_initialized))
|
||||||
g_mem_init_nomessage();
|
g_mem_init_nomessage();
|
||||||
@ -139,7 +139,7 @@ g_malloc (gulong n_bytes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gpointer
|
gpointer
|
||||||
g_malloc0 (gulong n_bytes)
|
g_malloc0 (gsize n_bytes)
|
||||||
{
|
{
|
||||||
if (G_UNLIKELY (!g_mem_initialized))
|
if (G_UNLIKELY (!g_mem_initialized))
|
||||||
g_mem_init_nomessage();
|
g_mem_init_nomessage();
|
||||||
@ -159,7 +159,7 @@ g_malloc0 (gulong n_bytes)
|
|||||||
|
|
||||||
gpointer
|
gpointer
|
||||||
g_realloc (gpointer mem,
|
g_realloc (gpointer mem,
|
||||||
gulong n_bytes)
|
gsize n_bytes)
|
||||||
{
|
{
|
||||||
if (G_UNLIKELY (!g_mem_initialized))
|
if (G_UNLIKELY (!g_mem_initialized))
|
||||||
g_mem_init_nomessage();
|
g_mem_init_nomessage();
|
||||||
@ -188,7 +188,7 @@ g_free (gpointer mem)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gpointer
|
gpointer
|
||||||
g_try_malloc (gulong n_bytes)
|
g_try_malloc (gsize n_bytes)
|
||||||
{
|
{
|
||||||
if (G_UNLIKELY (!g_mem_initialized))
|
if (G_UNLIKELY (!g_mem_initialized))
|
||||||
g_mem_init_nomessage();
|
g_mem_init_nomessage();
|
||||||
@ -199,7 +199,7 @@ g_try_malloc (gulong n_bytes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gpointer
|
gpointer
|
||||||
g_try_malloc0 (gulong n_bytes)
|
g_try_malloc0 (gsize n_bytes)
|
||||||
{
|
{
|
||||||
gpointer mem;
|
gpointer mem;
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ g_try_malloc0 (gulong n_bytes)
|
|||||||
|
|
||||||
gpointer
|
gpointer
|
||||||
g_try_realloc (gpointer mem,
|
g_try_realloc (gpointer mem,
|
||||||
gulong n_bytes)
|
gsize n_bytes)
|
||||||
{
|
{
|
||||||
if (G_UNLIKELY (!g_mem_initialized))
|
if (G_UNLIKELY (!g_mem_initialized))
|
||||||
g_mem_init_nomessage();
|
g_mem_init_nomessage();
|
||||||
@ -298,21 +298,21 @@ typedef enum {
|
|||||||
PROFILER_ZINIT = 4
|
PROFILER_ZINIT = 4
|
||||||
} ProfilerJob;
|
} ProfilerJob;
|
||||||
static guint *profile_data = NULL;
|
static guint *profile_data = NULL;
|
||||||
static gulong profile_allocs = 0;
|
static gsize profile_allocs = 0;
|
||||||
static gulong profile_zinit = 0;
|
static gsize profile_zinit = 0;
|
||||||
static gulong profile_frees = 0;
|
static gsize profile_frees = 0;
|
||||||
static GMutex *gmem_profile_mutex = NULL;
|
static GMutex *gmem_profile_mutex = NULL;
|
||||||
#ifdef G_ENABLE_DEBUG
|
#ifdef G_ENABLE_DEBUG
|
||||||
static volatile gulong g_trap_free_size = 0;
|
static volatile gsize g_trap_free_size = 0;
|
||||||
static volatile gulong g_trap_realloc_size = 0;
|
static volatile gsize g_trap_realloc_size = 0;
|
||||||
static volatile gulong g_trap_malloc_size = 0;
|
static volatile gsize g_trap_malloc_size = 0;
|
||||||
#endif /* G_ENABLE_DEBUG */
|
#endif /* G_ENABLE_DEBUG */
|
||||||
|
|
||||||
#define PROFILE_TABLE(f1,f2,f3) ( ( ((f3) << 2) | ((f2) << 1) | (f1) ) * (MEM_PROFILE_TABLE_SIZE + 1))
|
#define PROFILE_TABLE(f1,f2,f3) ( ( ((f3) << 2) | ((f2) << 1) | (f1) ) * (MEM_PROFILE_TABLE_SIZE + 1))
|
||||||
|
|
||||||
static void
|
static void
|
||||||
profiler_log (ProfilerJob job,
|
profiler_log (ProfilerJob job,
|
||||||
gulong n_bytes,
|
gsize n_bytes,
|
||||||
gboolean success)
|
gboolean success)
|
||||||
{
|
{
|
||||||
g_mutex_lock (gmem_profile_mutex);
|
g_mutex_lock (gmem_profile_mutex);
|
||||||
@ -389,9 +389,9 @@ void
|
|||||||
g_mem_profile (void)
|
g_mem_profile (void)
|
||||||
{
|
{
|
||||||
guint local_data[(MEM_PROFILE_TABLE_SIZE + 1) * 8 * sizeof (profile_data[0])];
|
guint local_data[(MEM_PROFILE_TABLE_SIZE + 1) * 8 * sizeof (profile_data[0])];
|
||||||
gulong local_allocs;
|
gsize local_allocs;
|
||||||
gulong local_zinit;
|
gsize local_zinit;
|
||||||
gulong local_frees;
|
gsize local_frees;
|
||||||
|
|
||||||
if (G_UNLIKELY (!g_mem_initialized))
|
if (G_UNLIKELY (!g_mem_initialized))
|
||||||
g_mem_init_nomessage();
|
g_mem_init_nomessage();
|
||||||
@ -429,14 +429,14 @@ g_mem_profile (void)
|
|||||||
static gpointer
|
static gpointer
|
||||||
profiler_try_malloc (gsize n_bytes)
|
profiler_try_malloc (gsize n_bytes)
|
||||||
{
|
{
|
||||||
gulong *p;
|
gsize *p;
|
||||||
|
|
||||||
#ifdef G_ENABLE_DEBUG
|
#ifdef G_ENABLE_DEBUG
|
||||||
if (g_trap_malloc_size == n_bytes)
|
if (g_trap_malloc_size == n_bytes)
|
||||||
G_BREAKPOINT ();
|
G_BREAKPOINT ();
|
||||||
#endif /* G_ENABLE_DEBUG */
|
#endif /* G_ENABLE_DEBUG */
|
||||||
|
|
||||||
p = standard_malloc (sizeof (gulong) * 2 + n_bytes);
|
p = standard_malloc (sizeof (gsize) * 2 + n_bytes);
|
||||||
|
|
||||||
if (p)
|
if (p)
|
||||||
{
|
{
|
||||||
@ -467,14 +467,14 @@ profiler_calloc (gsize n_blocks,
|
|||||||
gsize n_block_bytes)
|
gsize n_block_bytes)
|
||||||
{
|
{
|
||||||
gsize l = n_blocks * n_block_bytes;
|
gsize l = n_blocks * n_block_bytes;
|
||||||
gulong *p;
|
gsize *p;
|
||||||
|
|
||||||
#ifdef G_ENABLE_DEBUG
|
#ifdef G_ENABLE_DEBUG
|
||||||
if (g_trap_malloc_size == l)
|
if (g_trap_malloc_size == l)
|
||||||
G_BREAKPOINT ();
|
G_BREAKPOINT ();
|
||||||
#endif /* G_ENABLE_DEBUG */
|
#endif /* G_ENABLE_DEBUG */
|
||||||
|
|
||||||
p = standard_calloc (1, sizeof (gulong) * 2 + l);
|
p = standard_calloc (1, sizeof (gsize) * 2 + l);
|
||||||
|
|
||||||
if (p)
|
if (p)
|
||||||
{
|
{
|
||||||
@ -495,7 +495,7 @@ profiler_calloc (gsize n_blocks,
|
|||||||
static void
|
static void
|
||||||
profiler_free (gpointer mem)
|
profiler_free (gpointer mem)
|
||||||
{
|
{
|
||||||
gulong *p = mem;
|
gsize *p = mem;
|
||||||
|
|
||||||
p -= 2;
|
p -= 2;
|
||||||
if (p[0]) /* free count */
|
if (p[0]) /* free count */
|
||||||
@ -529,7 +529,7 @@ static gpointer
|
|||||||
profiler_try_realloc (gpointer mem,
|
profiler_try_realloc (gpointer mem,
|
||||||
gsize n_bytes)
|
gsize n_bytes)
|
||||||
{
|
{
|
||||||
gulong *p = mem;
|
gsize *p = mem;
|
||||||
|
|
||||||
p -= 2;
|
p -= 2;
|
||||||
|
|
||||||
@ -540,14 +540,14 @@ profiler_try_realloc (gpointer mem,
|
|||||||
|
|
||||||
if (mem && p[0]) /* free count */
|
if (mem && p[0]) /* free count */
|
||||||
{
|
{
|
||||||
g_warning ("realloc(%p, %lu): memory has been freed %lu times already", p + 2, (gulong)n_bytes, p[0]);
|
g_warning ("realloc(%p, %lu): memory has been freed %lu times already", p + 2, (gsize) n_bytes, p[0]);
|
||||||
profiler_log (PROFILER_ALLOC | PROFILER_RELOC, n_bytes, FALSE);
|
profiler_log (PROFILER_ALLOC | PROFILER_RELOC, n_bytes, FALSE);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p = standard_realloc (mem ? p : NULL, sizeof (gulong) * 2 + n_bytes);
|
p = standard_realloc (mem ? p : NULL, sizeof (gsize) * 2 + n_bytes);
|
||||||
|
|
||||||
if (p)
|
if (p)
|
||||||
{
|
{
|
||||||
@ -604,7 +604,7 @@ struct _GMemChunk {
|
|||||||
GMemChunk*
|
GMemChunk*
|
||||||
g_mem_chunk_new (const gchar *name,
|
g_mem_chunk_new (const gchar *name,
|
||||||
gint atom_size,
|
gint atom_size,
|
||||||
gulong area_size,
|
gsize area_size,
|
||||||
gint type)
|
gint type)
|
||||||
{
|
{
|
||||||
GMemChunk *mem_chunk;
|
GMemChunk *mem_chunk;
|
||||||
|
14
glib/gmem.h
14
glib/gmem.h
@ -44,15 +44,15 @@ typedef struct _GMemVTable GMemVTable;
|
|||||||
|
|
||||||
/* Memory allocation functions
|
/* Memory allocation functions
|
||||||
*/
|
*/
|
||||||
gpointer g_malloc (gulong n_bytes) G_GNUC_MALLOC;
|
gpointer g_malloc (gsize n_bytes) G_GNUC_MALLOC;
|
||||||
gpointer g_malloc0 (gulong n_bytes) G_GNUC_MALLOC;
|
gpointer g_malloc0 (gsize n_bytes) G_GNUC_MALLOC;
|
||||||
gpointer g_realloc (gpointer mem,
|
gpointer g_realloc (gpointer mem,
|
||||||
gulong n_bytes) G_GNUC_WARN_UNUSED_RESULT;
|
gsize n_bytes) G_GNUC_WARN_UNUSED_RESULT;
|
||||||
void g_free (gpointer mem);
|
void g_free (gpointer mem);
|
||||||
gpointer g_try_malloc (gulong n_bytes) G_GNUC_MALLOC;
|
gpointer g_try_malloc (gsize n_bytes) G_GNUC_MALLOC;
|
||||||
gpointer g_try_malloc0 (gulong n_bytes) G_GNUC_MALLOC;
|
gpointer g_try_malloc0 (gsize n_bytes) G_GNUC_MALLOC;
|
||||||
gpointer g_try_realloc (gpointer mem,
|
gpointer g_try_realloc (gpointer mem,
|
||||||
gulong n_bytes) G_GNUC_WARN_UNUSED_RESULT;
|
gsize n_bytes) G_GNUC_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
|
|
||||||
/* Convenience memory allocators
|
/* Convenience memory allocators
|
||||||
@ -123,7 +123,7 @@ typedef struct _GMemChunk GMemChunk;
|
|||||||
#define G_ALLOC_AND_FREE 2
|
#define G_ALLOC_AND_FREE 2
|
||||||
GMemChunk* g_mem_chunk_new (const gchar *name,
|
GMemChunk* g_mem_chunk_new (const gchar *name,
|
||||||
gint atom_size,
|
gint atom_size,
|
||||||
gulong area_size,
|
gsize area_size,
|
||||||
gint type);
|
gint type);
|
||||||
void g_mem_chunk_destroy (GMemChunk *mem_chunk);
|
void g_mem_chunk_destroy (GMemChunk *mem_chunk);
|
||||||
gpointer g_mem_chunk_alloc (GMemChunk *mem_chunk);
|
gpointer g_mem_chunk_alloc (GMemChunk *mem_chunk);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user