1
// included by glib2.pas
3
{$IFDEF read_forward_definitions}
4
{$ENDIF read_forward_definitions}
6
//------------------------------------------------------------------------------
8
{$IFDEF read_interface_rest}
10
G_MEM_ALIGN = GLIB_SIZEOF_VOID_P;
13
PGMemVTable = ^TGMemVTable;
15
malloc : function (n_bytes:gsize):gpointer; cdecl;
16
realloc : function (mem:gpointer; n_bytes:gsize):gpointer; cdecl;
17
free : procedure (mem:gpointer); cdecl;
18
calloc : function (n_blocks:gsize; n_block_bytes:gsize):gpointer; cdecl;
19
try_malloc : function (n_bytes:gsize):gpointer; cdecl;
20
try_realloc : function (mem:gpointer; n_bytes:gsize):gpointer; cdecl;
23
PGMemChunk = pointer; // internal structure of gmem.c
24
PGAllocator = pointer; // internal structure of gmem.c
27
{ Memory allocation functions }
29
function g_malloc(n_bytes:gulong):gpointer; cdecl; external gliblib;
30
function g_malloc0(n_bytes:gulong):gpointer; cdecl; external gliblib;
31
function g_realloc(mem:gpointer; n_bytes:gulong):gpointer; cdecl; external gliblib;
32
procedure g_free(mem:gpointer); cdecl; external gliblib;
33
function g_try_malloc(n_bytes:gulong):gpointer; cdecl; external gliblib;
34
function g_try_realloc(mem:gpointer; n_bytes:gulong):gpointer; cdecl; external gliblib;
36
{ Convenience memory allocators }
37
function g_new(bytes_per_struct, n_structs: gsize): gpointer;
38
function g_new0(bytes_per_struct, n_structs: gsize): gpointer;
39
function g_renew(struct_size: gsize; OldMem: gpointer; n_structs : gsize) : gpointer;
41
{ Memory allocation virtualization for debugging purposes
42
g_mem_set_vtable() has to be the very first GLib function called
47
procedure g_mem_set_vtable(vtable:PGMemVTable); cdecl; external gliblib;
48
function g_mem_is_system_malloc:gboolean; cdecl; external gliblib;
51
{ Memory profiler and checker, has to be enabled via g_mem_set_vtable() }
54
glib_mem_profiler_table : PGMemVTable; external gliblib name 'glib_mem_profiler_table';
56
glib_mem_profiler_table : PGMemVTable;cvar;external;
60
procedure g_mem_profile; cdecl; external gliblib;
61
{ Memchunk convenience functions }
64
#define g_mem_chunk_create(type, pre_alloc, alloc_type) (
65
g_mem_chunk_new (#type " mem chunks (" #pre_alloc ")",
66
sizeof (type), sizeof (type) * (pre_alloc), (alloc_type)) ) }
68
function g_chunk_new(chunk : Pointer) : Pointer;
69
function g_chunk_new0(chunk : Pointer) : Pointer;
70
procedure g_chunk_free(mem_chunk:PGMemChunk; mem:gpointer);
71
{ "g_mem_chunk_new" creates a new memory chunk.
72
Memory chunks are used to allocate pieces of memory which are
73
always the same size. Lists are a good example of such a data type.
74
The memory chunk allocates and frees blocks of memory as needed.
75
Just be sure to call "g_mem_chunk_free" and not "g_free" on data
76
allocated in a mem chunk. ("g_free" will most likely cause a seg
79
Oh yeah, GMemChunk is an opaque data type. (You don't really
80
want to know what's going on inside do you?)
82
{ ALLOC_ONLY MemChunk's can only allocate memory. The free operation
83
is interpreted as a no op. ALLOC_ONLY MemChunk's save 4 bytes per
84
atom. (They are also useful for lists which use MemChunk to allocate
85
memory but are also part of the MemChunk implementation).
86
ALLOC_AND_FREE MemChunk's can allocate and free memory.
93
function g_mem_chunk_new(name:Pgchar; atom_size:gint; area_size:gulong; _type:gint):PGMemChunk; cdecl; external gliblib;
94
procedure g_mem_chunk_destroy(mem_chunk:PGMemChunk); cdecl; external gliblib;
95
function g_mem_chunk_alloc(mem_chunk:PGMemChunk):gpointer; cdecl; external gliblib;
96
function g_mem_chunk_alloc0(mem_chunk:PGMemChunk):gpointer; cdecl; external gliblib;
97
procedure g_mem_chunk_free(mem_chunk:PGMemChunk; mem:gpointer); cdecl; external gliblib;
98
procedure g_mem_chunk_clean(mem_chunk:PGMemChunk); cdecl; external gliblib;
99
procedure g_mem_chunk_reset(mem_chunk:PGMemChunk); cdecl; external gliblib;
100
procedure g_mem_chunk_print(mem_chunk:PGMemChunk); cdecl; external gliblib;
101
procedure g_mem_chunk_info; cdecl; external gliblib;
103
{ Ah yes...we have a "g_blow_chunks" function.
104
"g_blow_chunks" simply compresses all the chunks. This operation
105
consists of freeing every memory area that should be freed (but
106
which we haven't gotten around to doing yet). And, no,
107
"g_blow_chunks" doesn't follow the naming scheme, but it is a
108
much better name than "g_mem_chunk_clean_all" or something
111
procedure g_blow_chunks; cdecl; external gliblib;
113
{ Generic allocators }
114
function g_allocator_new(name:Pgchar; n_preallocs:guint):PGAllocator; cdecl; external gliblib;
115
procedure g_allocator_free(allocator:PGAllocator); cdecl; external gliblib;
119
G_ALLOCATOR_LIST = 1;
120
G_ALLOCATOR_SLIST = 2;
121
G_ALLOCATOR_NODE = 3;
123
{$ENDIF read_interface_rest}
124
// included by glib2.pas