1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = glib-Memory-Allocators.html
27  * outPack = glib
28  * outFile = Allocator
29  * strct   = GAllocator
30  * realStrct=
31  * ctorStrct=
32  * clss    = Allocator
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_allocator_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * structWrap:
48  * module aliases:
49  * local aliases:
50  * overrides:
51  */
52 
53 module glib.Allocator;
54 
55 public  import gtkc.glibtypes;
56 
57 private import gtkc.glib;
58 private import glib.ConstructionException;
59 
60 
61 private import glib.Str;
62 
63 
64 
65 
66 /**
67  * Description
68  * Prior to 2.10, GAllocator was used as an efficient way to allocate
69  * small pieces of memory for use with the GList, GSList and GNode
70  * data structures. Since 2.10, it has been completely replaced by the
71  * slice allocator and
72  * deprecated.
73  */
74 public class Allocator
75 {
76 	
77 	/** the main Gtk struct */
78 	protected GAllocator* gAllocator;
79 	
80 	
81 	public GAllocator* getAllocatorStruct()
82 	{
83 		return gAllocator;
84 	}
85 	
86 	
87 	/** the main Gtk struct as a void* */
88 	protected void* getStruct()
89 	{
90 		return cast(void*)gAllocator;
91 	}
92 	
93 	/**
94 	 * Sets our main struct and passes it to the parent class
95 	 */
96 	public this (GAllocator* gAllocator)
97 	{
98 		this.gAllocator = gAllocator;
99 	}
100 	
101 	/**
102 	 */
103 	
104 	/**
105 	 * Warning
106 	 * g_allocator_new has been deprecated since version 2.10 and should not be used in newly-written code. Use the slice
107 	 *  allocator instead
108 	 * Creates a new GAllocator.
109 	 * Params:
110 	 * name = the name of the GAllocator. This name is used to set the
111 	 * name of the GMemChunk used by the GAllocator, and is only
112 	 * used for debugging.
113 	 * nPreallocs = the number of elements in each block of memory
114 	 * allocated. Larger blocks mean less calls to
115 	 * g_malloc(), but some memory may be wasted. (GLib uses
116 	 * 128 elements per block by default.) The value must be
117 	 * between 1 and 65535.
118 	 * Throws: ConstructionException GTK+ fails to create the object.
119 	 */
120 	public this (string name, uint nPreallocs)
121 	{
122 		// GAllocator * g_allocator_new (const gchar *name,  guint n_preallocs);
123 		auto p = g_allocator_new(Str.toStringz(name), nPreallocs);
124 		if(p is null)
125 		{
126 			throw new ConstructionException("null returned by g_allocator_new(Str.toStringz(name), nPreallocs)");
127 		}
128 		this(cast(GAllocator*) p);
129 	}
130 	
131 	/**
132 	 * Warning
133 	 * g_allocator_free has been deprecated since version 2.10 and should not be used in newly-written code. Use the slice
134 	 *  allocator instead
135 	 * Frees all of the memory allocated by the GAllocator.
136 	 */
137 	public void free()
138 	{
139 		// void g_allocator_free (GAllocator *allocator);
140 		g_allocator_free(gAllocator);
141 	}
142 }