1.1 --- a/epoc32/include/stdapis/glib-2.0/glib/gmem.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/stdapis/glib-2.0/glib/gmem.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,155 @@
1.4 -gmem.h
1.5 +/* GLIB - Library of useful routines for C programming
1.6 + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
1.7 + * Portions copyright (c) 2006 Nokia Corporation. All rights reserved.
1.8 + *
1.9 + * This library is free software; you can redistribute it and/or
1.10 + * modify it under the terms of the GNU Lesser General Public
1.11 + * License as published by the Free Software Foundation; either
1.12 + * version 2 of the License, or (at your option) any later version.
1.13 + *
1.14 + * This library is distributed in the hope that it will be useful,
1.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1.17 + * Lesser General Public License for more details.
1.18 + *
1.19 + * You should have received a copy of the GNU Lesser General Public
1.20 + * License along with this library; if not, write to the
1.21 + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1.22 + * Boston, MA 02111-1307, USA.
1.23 + */
1.24 +
1.25 +/*
1.26 + * Modified by the GLib Team and others 1997-2000. See the AUTHORS
1.27 + * file for a list of people on the GLib Team. See the ChangeLog
1.28 + * files for a list of changes. These files are distributed with
1.29 + * GLib at ftp://ftp.gtk.org/pub/gtk/.
1.30 + */
1.31 +
1.32 +#ifndef __G_MEM_H__
1.33 +#define __G_MEM_H__
1.34 +
1.35 +#include <_ansi.h>
1.36 +#include <glib/gtypes.h>
1.37 +
1.38 +G_BEGIN_DECLS
1.39 +
1.40 +typedef struct _GMemVTable GMemVTable;
1.41 +
1.42 +
1.43 +#if GLIB_SIZEOF_VOID_P > GLIB_SIZEOF_LONG
1.44 +# define G_MEM_ALIGN GLIB_SIZEOF_VOID_P
1.45 +#else /* GLIB_SIZEOF_VOID_P <= GLIB_SIZEOF_LONG */
1.46 +# define G_MEM_ALIGN GLIB_SIZEOF_LONG
1.47 +#endif /* GLIB_SIZEOF_VOID_P <= GLIB_SIZEOF_LONG */
1.48 +
1.49 +
1.50 +/* Memory allocation functions
1.51 + */
1.52 +IMPORT_C gpointer g_malloc (gulong n_bytes) G_GNUC_MALLOC;
1.53 +IMPORT_C gpointer g_malloc0 (gulong n_bytes) G_GNUC_MALLOC;
1.54 +IMPORT_C gpointer g_realloc (gpointer mem,
1.55 + gulong n_bytes) G_GNUC_WARN_UNUSED_RESULT;
1.56 +IMPORT_C void g_free (gpointer mem);
1.57 +IMPORT_C gpointer g_try_malloc (gulong n_bytes) G_GNUC_MALLOC;
1.58 +IMPORT_C gpointer g_try_malloc0 (gulong n_bytes) G_GNUC_MALLOC;
1.59 +IMPORT_C gpointer g_try_realloc (gpointer mem,
1.60 + gulong n_bytes) G_GNUC_WARN_UNUSED_RESULT;
1.61 +
1.62 +
1.63 +/* Convenience memory allocators
1.64 + */
1.65 +#define g_new(struct_type, n_structs) \
1.66 + ((struct_type *) g_malloc (((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
1.67 +#define g_new0(struct_type, n_structs) \
1.68 + ((struct_type *) g_malloc0 (((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
1.69 +#define g_renew(struct_type, mem, n_structs) \
1.70 + ((struct_type *) g_realloc ((mem), ((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
1.71 +
1.72 +#define g_try_new(struct_type, n_structs) \
1.73 + ((struct_type *) g_try_malloc (((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
1.74 +#define g_try_new0(struct_type, n_structs) \
1.75 + ((struct_type *) g_try_malloc0 (((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
1.76 +#define g_try_renew(struct_type, mem, n_structs) \
1.77 + ((struct_type *) g_try_realloc ((mem), ((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
1.78 +
1.79 +
1.80 +/* Memory allocation virtualization for debugging purposes
1.81 + * g_mem_set_vtable() has to be the very first GLib function called
1.82 + * if being used
1.83 + */
1.84 +struct _GMemVTable
1.85 +{
1.86 + gpointer (*malloc) (gsize n_bytes);
1.87 + gpointer (*realloc) (gpointer mem,
1.88 + gsize n_bytes);
1.89 + void (*free) (gpointer mem);
1.90 + /* optional; set to NULL if not used ! */
1.91 + gpointer (*calloc) (gsize n_blocks,
1.92 + gsize n_block_bytes);
1.93 + gpointer (*try_malloc) (gsize n_bytes);
1.94 + gpointer (*try_realloc) (gpointer mem,
1.95 + gsize n_bytes);
1.96 +};
1.97 +IMPORT_C void g_mem_set_vtable (GMemVTable *vtable);
1.98 +IMPORT_C gboolean g_mem_is_system_malloc (void);
1.99 +
1.100 +#ifdef __SYMBIAN32__
1.101 +IMPORT_C gboolean * _g_mem_gc_friendly();
1.102 +#endif /* __SYMBIAN32__ */
1.103 +GLIB_VAR gboolean g_mem_gc_friendly;
1.104 +
1.105 +/* Memory profiler and checker, has to be enabled via g_mem_set_vtable()*/
1.106 +#ifdef __SYMBIAN32__
1.107 +IMPORT_C GMemVTable ** _glib_mem_profiler_table();
1.108 +#endif /* __SYMBIAN32__ */
1.109 +GLIB_VAR GMemVTable *glib_mem_profiler_table;
1.110 +
1.111 +IMPORT_C void g_mem_profile (void);
1.112 +
1.113 +
1.114 +/* deprecated memchunks and allocators */
1.115 +#if !defined (G_DISABLE_DEPRECATED) || defined (GTK_COMPILATION) || defined (GDK_COMPILATION)
1.116 +typedef struct _GAllocator GAllocator;
1.117 +typedef struct _GMemChunk GMemChunk;
1.118 +#define g_mem_chunk_create(type, pre_alloc, alloc_type) ( \
1.119 + g_mem_chunk_new (#type " mem chunks (" #pre_alloc ")", \
1.120 + sizeof (type), \
1.121 + sizeof (type) * (pre_alloc), \
1.122 + (alloc_type)) \
1.123 +)
1.124 +#define g_chunk_new(type, chunk) ( \
1.125 + (type *) g_mem_chunk_alloc (chunk) \
1.126 +)
1.127 +#define g_chunk_new0(type, chunk) ( \
1.128 + (type *) g_mem_chunk_alloc0 (chunk) \
1.129 +)
1.130 +#define g_chunk_free(mem, mem_chunk) G_STMT_START { \
1.131 + g_mem_chunk_free ((mem_chunk), (mem)); \
1.132 +} G_STMT_END
1.133 +#define G_ALLOC_ONLY 1
1.134 +#define G_ALLOC_AND_FREE 2
1.135 +IMPORT_C GMemChunk* g_mem_chunk_new (const gchar *name,
1.136 + gint atom_size,
1.137 + gulong area_size,
1.138 + gint type);
1.139 +IMPORT_C void g_mem_chunk_destroy (GMemChunk *mem_chunk);
1.140 +IMPORT_C gpointer g_mem_chunk_alloc (GMemChunk *mem_chunk);
1.141 +IMPORT_C gpointer g_mem_chunk_alloc0 (GMemChunk *mem_chunk);
1.142 +IMPORT_C void g_mem_chunk_free (GMemChunk *mem_chunk,
1.143 + gpointer mem);
1.144 +IMPORT_C void g_mem_chunk_clean (GMemChunk *mem_chunk);
1.145 +IMPORT_C void g_mem_chunk_reset (GMemChunk *mem_chunk);
1.146 +IMPORT_C void g_mem_chunk_print (GMemChunk *mem_chunk);
1.147 +IMPORT_C void g_mem_chunk_info (void);
1.148 +IMPORT_C void g_blow_chunks (void);
1.149 +IMPORT_C GAllocator* g_allocator_new (const gchar *name,
1.150 + guint n_preallocs);
1.151 +IMPORT_C void g_allocator_free (GAllocator *allocator);
1.152 +#define G_ALLOCATOR_LIST (1)
1.153 +#define G_ALLOCATOR_SLIST (2)
1.154 +#define G_ALLOCATOR_NODE (3)
1.155 +#endif /* G_DISABLE_DEPRECATED */
1.156 +
1.157 +G_END_DECLS
1.158 +
1.159 +#endif /* __G_MEM_H__ */