Skip to content

Commit

Permalink
Use g_malloc0 to allocate the structs for out params, so the GC doesn…
Browse files Browse the repository at this point in the history
…'t collect them.
  • Loading branch information
MikeWey committed Jan 16, 2016
1 parent 682ccd5 commit 18bf92c
Show file tree
Hide file tree
Showing 55 changed files with 155 additions and 136 deletions.
2 changes: 1 addition & 1 deletion src/gdk/Color.d
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public class Color
*/
public static bool parse(string spec, out Color color)
{
GdkColor* outcolor = new GdkColor;
GdkColor* outcolor = gMalloc!GdkColor();

auto p = gdk_color_parse(Str.toStringz(spec), outcolor) != 0;

Expand Down
2 changes: 1 addition & 1 deletion src/gio/DBusInterfaceInfo.d
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public class DBusInterfaceInfo
*/
public void generateXml(uint indent, out StringG stringBuilder)
{
GString* outstringBuilder = new GString;
GString* outstringBuilder = gMalloc!GString();

g_dbus_interface_info_generate_xml(gDBusInterfaceInfo, indent, outstringBuilder);

Expand Down
2 changes: 1 addition & 1 deletion src/gio/DBusNodeInfo.d
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public class DBusNodeInfo
*/
public void generateXml(uint indent, out StringG stringBuilder)
{
GString* outstringBuilder = new GString;
GString* outstringBuilder = gMalloc!GString();

g_dbus_node_info_generate_xml(gDBusNodeInfo, indent, outstringBuilder);

Expand Down
2 changes: 1 addition & 1 deletion src/gio/DBusUtilities.d
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public struct DBusUtilities
*/
public static void gvariantToGvalue(Variant value, out Value outGvalue)
{
GValue* outoutGvalue = new GValue;
GValue* outoutGvalue = gMalloc!GValue();

g_dbus_gvariant_to_gvalue((value is null) ? null : value.getVariantStruct(), outoutGvalue);

Expand Down
2 changes: 1 addition & 1 deletion src/gio/FileInfo.d
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ public class FileInfo : ObjectG
*/
public void getModificationTime(out TimeVal result)
{
GTimeVal* outresult = new GTimeVal;
GTimeVal* outresult = gMalloc!GTimeVal();

g_file_info_get_modification_time(gFileInfo, outresult);

Expand Down
2 changes: 1 addition & 1 deletion src/glib/TimeVal.d
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public class TimeVal
*/
public static bool fromIso8601(string isoDate, out TimeVal time)
{
GTimeVal* outtime = new GTimeVal;
GTimeVal* outtime = gMalloc!GTimeVal();

auto p = g_time_val_from_iso8601(Str.toStringz(isoDate), outtime) != 0;

Expand Down
4 changes: 2 additions & 2 deletions src/gtk/Builder.d
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ public void setTranslationDomain(string domain)
*/
public bool valueFromString(ParamSpec pspec, string str, out Value value)
{
GValue* outvalue = new GValue;
GValue* outvalue = gMalloc!GValue();
GError* err = null;

auto p = gtk_builder_value_from_string(gtkBuilder, (pspec is null) ? null : pspec.getParamSpecStruct(), Str.toStringz(str), outvalue, &err) != 0;
Expand Down Expand Up @@ -969,7 +969,7 @@ public bool valueFromString(ParamSpec pspec, string str, out Value value)
*/
public bool valueFromStringType(GType type, string str, out Value value)
{
GValue* outvalue = new GValue;
GValue* outvalue = gMalloc!GValue();
GError* err = null;

auto p = gtk_builder_value_from_string_type(gtkBuilder, type, Str.toStringz(str), outvalue, &err) != 0;
Expand Down
4 changes: 2 additions & 2 deletions src/gtk/CellRenderer.d
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ public class CellRenderer : ObjectG
*/
public void getPreferredSize(Widget widget, out Requisition minimumSize, out Requisition naturalSize)
{
GtkRequisition* outminimumSize = new GtkRequisition;
GtkRequisition* outnaturalSize = new GtkRequisition;
GtkRequisition* outminimumSize = gMalloc!GtkRequisition();
GtkRequisition* outnaturalSize = gMalloc!GtkRequisition();

gtk_cell_renderer_get_preferred_size(gtkCellRenderer, (widget is null) ? null : widget.getWidgetStruct(), outminimumSize, outnaturalSize);

Expand Down
2 changes: 1 addition & 1 deletion src/gtk/CellView.d
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public class CellView : Widget, CellLayoutIF, OrientableIF
*/
public bool getSizeOfRow(TreePath path, out Requisition requisition)
{
GtkRequisition* outrequisition = new GtkRequisition;
GtkRequisition* outrequisition = gMalloc!GtkRequisition();

auto p = gtk_cell_view_get_size_of_row(gtkCellView, (path is null) ? null : path.getTreePathStruct(), outrequisition) != 0;

Expand Down
2 changes: 1 addition & 1 deletion src/gtk/ColorButton.d
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public class ColorButton : Button, ColorChooserIF
*/
public void getColor(out Color color)
{
GdkColor* outcolor = new GdkColor;
GdkColor* outcolor = gMalloc!GdkColor();

gtk_color_button_get_color(gtkColorButton, outcolor);

Expand Down
2 changes: 1 addition & 1 deletion src/gtk/ColorChooserT.d
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public template ColorChooserT(TStruct)
*/
public void getRgba(out RGBA color)
{
GdkRGBA* outcolor = new GdkRGBA;
GdkRGBA* outcolor = gMalloc!GdkRGBA();

gtk_color_chooser_get_rgba(getColorChooserStruct(), outcolor);

Expand Down
8 changes: 4 additions & 4 deletions src/gtk/ColorSelection.d
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public class ColorSelection : Box
*/
public void getCurrentColor(out Color color)
{
GdkColor* outcolor = new GdkColor;
GdkColor* outcolor = gMalloc!GdkColor();

gtk_color_selection_get_current_color(gtkColorSelection, outcolor);

Expand All @@ -200,7 +200,7 @@ public class ColorSelection : Box
*/
public void getCurrentRgba(out RGBA rgba)
{
GdkRGBA* outrgba = new GdkRGBA;
GdkRGBA* outrgba = gMalloc!GdkRGBA();

gtk_color_selection_get_current_rgba(gtkColorSelection, outrgba);

Expand Down Expand Up @@ -248,7 +248,7 @@ public class ColorSelection : Box
*/
public void getPreviousColor(out Color color)
{
GdkColor* outcolor = new GdkColor;
GdkColor* outcolor = gMalloc!GdkColor();

gtk_color_selection_get_previous_color(gtkColorSelection, outcolor);

Expand All @@ -265,7 +265,7 @@ public class ColorSelection : Box
*/
public void getPreviousRgba(out RGBA rgba)
{
GdkRGBA* outrgba = new GdkRGBA;
GdkRGBA* outrgba = gMalloc!GdkRGBA();

gtk_color_selection_get_previous_rgba(gtkColorSelection, outrgba);

Expand Down
2 changes: 1 addition & 1 deletion src/gtk/ComboBox.d
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public class ComboBox : Bin, CellEditableIF, CellLayoutIF
*/
public bool getActiveIter(out TreeIter iter)
{
GtkTreeIter* outiter = new GtkTreeIter;
GtkTreeIter* outiter = gMalloc!GtkTreeIter();

auto p = gtk_combo_box_get_active_iter(gtkComboBox, outiter) != 0;

Expand Down
2 changes: 1 addition & 1 deletion src/gtk/IconView.d
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ public class IconView : Container, CellLayoutIF, ScrollableIF
{
GtkTreeModel* outmodel = null;
GtkTreePath* outpath = null;
GtkTreeIter* outiter = new GtkTreeIter;
GtkTreeIter* outiter = gMalloc!GtkTreeIter();

auto p = gtk_icon_view_get_tooltip_context(gtkIconView, &x, &y, keyboardTip, &outmodel, &outpath, outiter) != 0;

Expand Down
12 changes: 6 additions & 6 deletions src/gtk/ListStore.d
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ public class ListStore : ObjectG, BuildableIF, TreeDragDestIF, TreeDragSourceIF,
*/
public void append(out TreeIter iter)
{
GtkTreeIter* outiter = new GtkTreeIter;
GtkTreeIter* outiter = gMalloc!GtkTreeIter();

gtk_list_store_append(gtkListStore, outiter);

Expand Down Expand Up @@ -353,7 +353,7 @@ public class ListStore : ObjectG, BuildableIF, TreeDragDestIF, TreeDragSourceIF,
*/
public void insert(out TreeIter iter, int position)
{
GtkTreeIter* outiter = new GtkTreeIter;
GtkTreeIter* outiter = gMalloc!GtkTreeIter();

gtk_list_store_insert(gtkListStore, outiter, position);

Expand All @@ -372,7 +372,7 @@ public class ListStore : ObjectG, BuildableIF, TreeDragDestIF, TreeDragSourceIF,
*/
public void insertAfter(out TreeIter iter, TreeIter sibling)
{
GtkTreeIter* outiter = new GtkTreeIter;
GtkTreeIter* outiter = gMalloc!GtkTreeIter();

gtk_list_store_insert_after(gtkListStore, outiter, (sibling is null) ? null : sibling.getTreeIterStruct());

Expand All @@ -391,7 +391,7 @@ public class ListStore : ObjectG, BuildableIF, TreeDragDestIF, TreeDragSourceIF,
*/
public void insertBefore(out TreeIter iter, TreeIter sibling)
{
GtkTreeIter* outiter = new GtkTreeIter;
GtkTreeIter* outiter = gMalloc!GtkTreeIter();

gtk_list_store_insert_before(gtkListStore, outiter, (sibling is null) ? null : sibling.getTreeIterStruct());

Expand All @@ -415,7 +415,7 @@ public class ListStore : ObjectG, BuildableIF, TreeDragDestIF, TreeDragSourceIF,
*/
public void insertWithValuesv(out TreeIter iter, int position, int[] columns, Value[] values)
{
GtkTreeIter* outiter = new GtkTreeIter;
GtkTreeIter* outiter = gMalloc!GtkTreeIter();

GValue[] valuesArray = new GValue[values.length];
for ( int i = 0; i < values.length; i++ )
Expand Down Expand Up @@ -488,7 +488,7 @@ public class ListStore : ObjectG, BuildableIF, TreeDragDestIF, TreeDragSourceIF,
*/
public void prepend(out TreeIter iter)
{
GtkTreeIter* outiter = new GtkTreeIter;
GtkTreeIter* outiter = gMalloc!GtkTreeIter();

gtk_list_store_prepend(gtkListStore, outiter);

Expand Down
4 changes: 2 additions & 2 deletions src/gtk/RcStyle.d
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ public class RcStyle : ObjectG
*/
public static uint parseColor(ScannerG scanner, out Color color)
{
GdkColor* outcolor = new GdkColor;
GdkColor* outcolor = gMalloc!GdkColor();

auto p = gtk_rc_parse_color((scanner is null) ? null : scanner.getScannerGStruct(), outcolor);

Expand Down Expand Up @@ -391,7 +391,7 @@ public class RcStyle : ObjectG
*/
public static uint parseColorFull(ScannerG scanner, RcStyle style, out Color color)
{
GdkColor* outcolor = new GdkColor;
GdkColor* outcolor = gMalloc!GdkColor();

auto p = gtk_rc_parse_color_full((scanner is null) ? null : scanner.getScannerGStruct(), (style is null) ? null : style.getRcStyleStruct(), outcolor);

Expand Down
12 changes: 6 additions & 6 deletions src/gtk/ScaleButton.d
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ public class ScaleButton : Button, OrientableIF
/**
* Retrieves the minus button of the #GtkScaleButton.
*
* Return: the minus button of the #GtkScaleButton
* Return: the minus button of the #GtkScaleButton as a #GtkButton
*
* Since: 2.14
*/
public Widget getMinusButton()
public Button getMinusButton()
{
auto p = gtk_scale_button_get_minus_button(gtkScaleButton);

Expand All @@ -153,17 +153,17 @@ public class ScaleButton : Button, OrientableIF
return null;
}

return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
return ObjectG.getDObject!(Button)(cast(GtkButton*) p);
}

/**
* Retrieves the plus button of the #GtkScaleButton.
*
* Return: the plus button of the #GtkScaleButton
* Return: the plus button of the #GtkScaleButton as a #GtkButton
*
* Since: 2.14
*/
public Widget getPlusButton()
public Button getPlusButton()
{
auto p = gtk_scale_button_get_plus_button(gtkScaleButton);

Expand All @@ -172,7 +172,7 @@ public class ScaleButton : Button, OrientableIF
return null;
}

return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
return ObjectG.getDObject!(Button)(cast(GtkButton*) p);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/gtk/StockItem.d
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public class StockItem
*/
public static bool stockLookup(string stockId, out StockItem item)
{
GtkStockItem* outitem = new GtkStockItem;
GtkStockItem* outitem = gMalloc!GtkStockItem();

auto p = gtk_stock_lookup(Str.toStringz(stockId), outitem) != 0;

Expand Down
4 changes: 2 additions & 2 deletions src/gtk/Style.d
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public class Style : ObjectG
*/
public void getStyleProperty(GType widgetType, string propertyName, out Value value)
{
GValue* outvalue = new GValue;
GValue* outvalue = gMalloc!GValue();

gtk_style_get_style_property(gtkStyle, widgetType, Str.toStringz(propertyName), outvalue);

Expand Down Expand Up @@ -266,7 +266,7 @@ public class Style : ObjectG
*/
public bool lookupColor(string colorName, out Color color)
{
GdkColor* outcolor = new GdkColor;
GdkColor* outcolor = gMalloc!GdkColor();

auto p = gtk_style_lookup_color(gtkStyle, Str.toStringz(colorName), outcolor) != 0;

Expand Down
18 changes: 9 additions & 9 deletions src/gtk/StyleContext.d
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ public class StyleContext : ObjectG
*/
public void getBackgroundColor(GtkStateFlags state, out RGBA color)
{
GdkRGBA* outcolor = new GdkRGBA;
GdkRGBA* outcolor = gMalloc!GdkRGBA();

gtk_style_context_get_background_color(gtkStyleContext, state, outcolor);

Expand All @@ -394,7 +394,7 @@ public class StyleContext : ObjectG
*/
public void getBorder(GtkStateFlags state, out Border border)
{
GtkBorder* outborder = new GtkBorder;
GtkBorder* outborder = gMalloc!GtkBorder();

gtk_style_context_get_border(gtkStyleContext, state, outborder);

Expand All @@ -414,7 +414,7 @@ public class StyleContext : ObjectG
*/
public void getBorderColor(GtkStateFlags state, out RGBA color)
{
GdkRGBA* outcolor = new GdkRGBA;
GdkRGBA* outcolor = gMalloc!GdkRGBA();

gtk_style_context_get_border_color(gtkStyleContext, state, outcolor);

Expand All @@ -432,7 +432,7 @@ public class StyleContext : ObjectG
*/
public void getColor(GtkStateFlags state, out RGBA color)
{
GdkRGBA* outcolor = new GdkRGBA;
GdkRGBA* outcolor = gMalloc!GdkRGBA();

gtk_style_context_get_color(gtkStyleContext, state, outcolor);

Expand Down Expand Up @@ -528,7 +528,7 @@ public class StyleContext : ObjectG
*/
public void getMargin(GtkStateFlags state, out Border margin)
{
GtkBorder* outmargin = new GtkBorder;
GtkBorder* outmargin = gMalloc!GtkBorder();

gtk_style_context_get_margin(gtkStyleContext, state, outmargin);

Expand All @@ -547,7 +547,7 @@ public class StyleContext : ObjectG
*/
public void getPadding(GtkStateFlags state, out Border padding)
{
GtkBorder* outpadding = new GtkBorder;
GtkBorder* outpadding = gMalloc!GtkBorder();

gtk_style_context_get_padding(gtkStyleContext, state, outpadding);

Expand Down Expand Up @@ -608,7 +608,7 @@ public class StyleContext : ObjectG
*/
public void getProperty(string property, GtkStateFlags state, out Value value)
{
GValue* outvalue = new GValue;
GValue* outvalue = gMalloc!GValue();

gtk_style_context_get_property(gtkStyleContext, Str.toStringz(property), state, outvalue);

Expand Down Expand Up @@ -833,7 +833,7 @@ public class StyleContext : ObjectG
*/
public bool lookupColor(string colorName, out RGBA color)
{
GdkRGBA* outcolor = new GdkRGBA;
GdkRGBA* outcolor = gMalloc!GdkRGBA();

auto p = gtk_style_context_lookup_color(gtkStyleContext, Str.toStringz(colorName), outcolor) != 0;

Expand Down Expand Up @@ -1287,7 +1287,7 @@ public class StyleContext : ObjectG
/**
* Renders an arrow pointing to @angle.
*
* Typical arrow rendering at 0, 1&solidus;2 &pi;, &pi; and 3&solidus;2 &pi;:
* Typical arrow rendering at 0, 1⁄2 π;, π; and 3⁄2 π:
*
* ![](arrows.png)
*
Expand Down
2 changes: 1 addition & 1 deletion src/gtk/StyleProperties.d
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public class StyleProperties : ObjectG, StyleProviderIF
*/
public bool getStyleProperty(string property, GtkStateFlags state, out Value value)
{
GValue* outvalue = new GValue;
GValue* outvalue = gMalloc!GValue();

auto p = gtk_style_properties_get_property(gtkStyleProperties, Str.toStringz(property), state, outvalue) != 0;

Expand Down
Loading

0 comments on commit 18bf92c

Please sign in to comment.