~ubuntu-branches/debian/lenny/fpc/lenny

« back to all changes in this revision

Viewing changes to fpcsrc/packages/extra/gtk2/glib/gmem.inc

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-05-17 17:12:11 UTC
  • mfrom: (3.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080517171211-9qi33xhd9evfa0kg
Tags: 2.2.0-dfsg1-9
[ Torsten Werner ]
* Add Mazen Neifer to Uploaders field.

[ Mazen Neifer ]
* Moved FPC sources into a version dependent directory from /usr/share/fpcsrc
  to /usr/share/fpcsrc/${FPCVERSION}. This allow installing more than on FPC
  release.
* Fixed far call issue in compiler preventing building huge binearies.
  (closes: #477743)
* Updated building dependencies, recomennded and suggested packages.
* Moved fppkg to fp-utils as it is just a helper tool and is not required by
  compiler.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// included by glib2.pas
 
2
 
 
3
{$IFDEF read_forward_definitions}
 
4
{$ENDIF read_forward_definitions}
 
5
 
 
6
//------------------------------------------------------------------------------
 
7
 
 
8
{$IFDEF read_interface_rest}
 
9
const
 
10
   G_MEM_ALIGN = GLIB_SIZEOF_VOID_P;
 
11
 
 
12
type
 
13
   PGMemVTable = ^TGMemVTable;
 
14
   TGMemVTable = record
 
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;
 
21
     end;
 
22
 
 
23
   PGMemChunk = pointer; // internal structure of gmem.c
 
24
   PGAllocator = pointer; // internal structure of gmem.c
 
25
 
 
26
 
 
27
{ Memory allocation functions }
 
28
 
 
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;
 
35
 
 
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;
 
40
 
 
41
{ Memory allocation virtualization for debugging purposes
 
42
   g_mem_set_vtable() has to be the very first GLib function called
 
43
   if being used
 
44
  }
 
45
{ optional  }
 
46
 
 
47
procedure g_mem_set_vtable(vtable:PGMemVTable); cdecl; external gliblib;
 
48
function g_mem_is_system_malloc:gboolean; cdecl; external gliblib;
 
49
 
 
50
{$IFNDEF KYLIX}
 
51
{ Memory profiler and checker, has to be enabled via g_mem_set_vtable() }
 
52
var
 
53
  {$IFDEF WIN32}
 
54
  glib_mem_profiler_table : PGMemVTable; external gliblib name 'glib_mem_profiler_table';
 
55
  {$ELSE}
 
56
  glib_mem_profiler_table : PGMemVTable;cvar;external;
 
57
  {$ENDIF}
 
58
{$ENDIF}
 
59
 
 
60
procedure g_mem_profile; cdecl; external gliblib;
 
61
{ Memchunk convenience functions }
 
62
 
 
63
{ c specific:
 
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)) ) }
 
67
 
 
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
 
77
    fault...somewhere).
 
78
 
 
79
   Oh yeah, GMemChunk is an opaque data type. (You don't really
 
80
    want to know what's going on inside do you?)
 
81
  }
 
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.
 
87
  }
 
88
 
 
89
const
 
90
   G_ALLOC_ONLY = 1;
 
91
   G_ALLOC_AND_FREE = 2;
 
92
 
 
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;
 
102
 
 
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
 
109
    similar.
 
110
  }
 
111
procedure g_blow_chunks; cdecl; external gliblib;
 
112
 
 
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;
 
116
 
 
117
{ internal  }
 
118
const
 
119
   G_ALLOCATOR_LIST = 1;
 
120
   G_ALLOCATOR_SLIST = 2;
 
121
   G_ALLOCATOR_NODE = 3;
 
122
 
 
123
{$ENDIF read_interface_rest}
 
124
// included by glib2.pas
 
125