Permalink
Browse files

Free the C string that are copied to the GC heap. See #146

  • Loading branch information...
1 parent 8ea8e39 commit 83cab4a45f27c5a0551185abe3f76248c3e368f7 @MikeWey MikeWey committed Feb 28, 2016
Showing with 1,426 additions and 626 deletions.
  1. +4 −1 src/atk/Hyperlink.d
  2. +4 −1 src/atk/Plug.d
  3. +24 −6 src/atk/TextT.d
  4. +8 −2 src/gdk/Atom.d
  5. +4 −1 src/gdk/Color.d
  6. +4 −1 src/gdk/Gdk.d
  7. +4 −1 src/gdk/RGBA.d
  8. +8 −2 src/gdk/Screen.d
  9. +20 −5 src/gdkpixbuf/PixbufFormat.d
  10. +4 −1 src/gio/ActionGroupT.d
  11. +4 −1 src/gio/ActionT.d
  12. +12 −3 src/gio/AppLaunchContext.d
  13. +4 −1 src/gio/ApplicationCommandLine.d
  14. +23 −7 src/gio/ContentType.d
  15. +4 −1 src/gio/Credentials.d
  16. +8 −2 src/gio/DBusError.d
  17. +4 −1 src/gio/DBusMessage.d
  18. +4 −1 src/gio/DBusObjectManagerClient.d
  19. +8 −2 src/gio/DBusProxy.d
  20. +11 −4 src/gio/DBusUtilities.d
  21. +24 −16 src/gio/DataInputStream.d
  22. +12 −3 src/gio/DesktopAppInfo.d
  23. +12 −3 src/gio/DriveT.d
  24. +4 −1 src/gio/FileAttributeMatcher.d
  25. +4 −1 src/gio/FileIOStream.d
  26. +8 −2 src/gio/FileInfo.d
  27. +4 −1 src/gio/FileOutputStream.d
  28. +24 −6 src/gio/FileT.d
  29. +8 −2 src/gio/FilenameCompleter.d
  30. +4 −1 src/gio/IOModule.d
  31. +4 −1 src/gio/IconT.d
  32. +4 −1 src/gio/InetAddress.d
  33. +4 −1 src/gio/InetAddressMask.d
  34. +14 −6 src/gio/MountT.d
  35. +6 −4 src/gio/ProxyResolverT.d
  36. +6 −4 src/gio/Resolver.d
  37. +6 −4 src/gio/Resource.d
  38. +16 −4 src/gio/Settings.d
  39. +8 −2 src/gio/SettingsSchema.d
  40. +4 −1 src/gio/TlsDatabase.d
  41. +4 −1 src/gio/UnixMountEntry.d
  42. +4 −1 src/gio/UnixMountPoint.d
  43. +16 −4 src/gio/VolumeT.d
  44. +4 −1 src/glib/ArrayG.d
  45. +4 −1 src/glib/Base64.d
  46. +22 −13 src/glib/BookmarkFile.d
  47. +33 −17 src/glib/CharacterSet.d
  48. +12 −3 src/glib/Checksum.d
  49. +4 −1 src/glib/DateTime.d
  50. +3 −2 src/glib/Directory.d
  51. +11 −4 src/glib/FileUtils.d
  52. +8 −2 src/glib/Hmac.d
  53. +8 −2 src/glib/Hostname.d
  54. +4 −1 src/glib/Internationalization.d
  55. +32 −18 src/glib/KeyFile.d
  56. +4 −1 src/glib/MappedFile.d
  57. +15 −5 src/glib/MatchInfo.d
  58. +4 −1 src/glib/Module.d
  59. +4 −1 src/glib/OptionContext.d
  60. +28 −12 src/glib/Regex.d
  61. +7 −3 src/glib/ShellUtils.d
  62. +8 −2 src/glib/SimpleXML.d
  63. +115 −130 src/glib/Str.d
  64. +12 −3 src/glib/StringChunk.d
  65. +4 −1 src/glib/StringG.d
  66. +4 −1 src/glib/TimeVal.d
  67. +26 −9 src/glib/URI.d
  68. +66 −19 src/glib/Unicode.d
  69. +44 −11 src/glib/Util.d
  70. +28 −7 src/glib/Variant.d
  71. +4 −1 src/glib/VariantType.d
  72. +8 −2 src/gobject/Value.d
  73. +16 −4 src/gtk/AccelGroup.d
  74. +4 −1 src/gtk/AppChooserT.d
  75. +12 −3 src/gtk/Application.d
  76. +8 −2 src/gtk/Clipboard.d
  77. +4 −1 src/gtk/ColorSelection.d
  78. +4 −1 src/gtk/ComboBoxText.d
  79. +4 −1 src/gtk/CssProvider.d
  80. +4 −1 src/gtk/EditableT.d
  81. +8 −2 src/gtk/Entry.d
  82. +4 −1 src/gtk/EntryCompletion.d
  83. +28 −7 src/gtk/FileChooserT.d
  84. +8 −2 src/gtk/FontChooserT.d
  85. +4 −1 src/gtk/FontSelection.d
  86. +4 −1 src/gtk/FontSelectionDialog.d
  87. +4 −1 src/gtk/Gradient.d
  88. +4 −1 src/gtk/IconTheme.d
  89. +24 −6 src/gtk/RcStyle.d
  90. +8 −2 src/gtk/RecentChooserT.d
  91. +20 −5 src/gtk/RecentInfo.d
  92. +8 −2 src/gtk/SelectionData.d
  93. +8 −2 src/gtk/StatusIcon.d
  94. +4 −1 src/gtk/SymbolicColor.d
  95. +4 −1 src/gtk/Testing.d
  96. +8 −2 src/gtk/TextBuffer.d
  97. +16 −4 src/gtk/TextIter.d
  98. +4 −1 src/gtk/TreeModelT.d
  99. +4 −1 src/gtk/TreePath.d
  100. +4 −1 src/gtk/UIManager.d
  101. +12 −3 src/gtk/Widget.d
  102. +4 −1 src/gtk/WidgetPath.d
  103. +4 −1 src/pango/PgColor.d
  104. +8 −2 src/pango/PgFontDescription.d
  105. +16 −4 src/pango/PgMiscellaneous.d
  106. +4 −1 srcgstreamer/gstreamer/Caps.d
  107. +4 −1 srcgstreamer/gstreamer/CapsFeatures.d
  108. +4 −1 srcgstreamer/gstreamer/DateTime.d
  109. +8 −2 srcgstreamer/gstreamer/Debug.d
  110. +8 −2 srcgstreamer/gstreamer/Device.d
  111. +4 −1 srcgstreamer/gstreamer/DeviceMonitor.d
  112. +4 −1 srcgstreamer/gstreamer/DeviceProvider.d
  113. +4 −1 srcgstreamer/gstreamer/DeviceProviderFactory.d
  114. +4 −1 srcgstreamer/gstreamer/ElementFactory.d
  115. +4 −1 srcgstreamer/gstreamer/GError.d
  116. +4 −1 srcgstreamer/gstreamer/GStreamer.d
  117. +8 −2 srcgstreamer/gstreamer/ObjectGst.d
  118. +12 −3 srcgstreamer/gstreamer/Pad.d
  119. +4 −1 srcgstreamer/gstreamer/ParseContext.d
  120. +8 −2 srcgstreamer/gstreamer/PresetT.d
  121. +4 −1 srcgstreamer/gstreamer/Structure.d
  122. +4 −1 srcgstreamer/gstreamer/TagList.d
  123. +4 −1 srcgstreamer/gstreamer/URIHandlerT.d
  124. +35 −10 srcgstreamer/gstreamer/Uri.d
  125. +4 −1 srcgstreamer/gstreamer/ValueGst.d
  126. +4 −1 srcsv/gsv/SourceBuffer.d
  127. +16 −4 srcsv/gsv/SourceCompletionProposalT.d
  128. +4 −1 srcsv/gsv/SourceCompletionProviderT.d
  129. +4 −1 srcsv/gsv/SourceEncoding.d
  130. +12 −3 srcsv/gsv/SourceLanguage.d
  131. +8 −2 srcsv/gsv/SourceMarkAttributes.d
  132. +16 −4 srcsv/gsv/SourcePrintCompositor.d
  133. +8 −2 srcsv/gsv/Utils.d
  134. +21 −9 srcvte/vte/Terminal.d
  135. +18 −103 wrap/APILookupGLib.txt
  136. +12 −4 wrap/utils/GtkFunction.d
View
@@ -154,7 +154,10 @@ public class Hyperlink : ObjectG, ActionIF
*/
public string getUri(int i)
{
- return Str.toString(atk_hyperlink_get_uri(atkHyperlink, i));
+ auto retStr = atk_hyperlink_get_uri(atkHyperlink, i);
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
/**
View
@@ -108,6 +108,9 @@ public class Plug : ObjectAtk, ComponentIF
*/
public string getId()
{
- return Str.toString(atk_plug_get_id(atkPlug));
+ auto retStr = atk_plug_get_id(atkPlug);
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
}
View
@@ -267,7 +267,10 @@ public template TextT(TStruct)
*/
public string getSelection(int selectionNum, out int startOffset, out int endOffset)
{
- return Str.toString(atk_text_get_selection(getTextStruct(), selectionNum, &startOffset, &endOffset));
+ auto retStr = atk_text_get_selection(getTextStruct(), selectionNum, &startOffset, &endOffset);
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
/**
@@ -319,7 +322,10 @@ public template TextT(TStruct)
*/
public string getStringAtOffset(int offset, AtkTextGranularity granularity, out int startOffset, out int endOffset)
{
- return Str.toString(atk_text_get_string_at_offset(getTextStruct(), offset, granularity, &startOffset, &endOffset));
+ auto retStr = atk_text_get_string_at_offset(getTextStruct(), offset, granularity, &startOffset, &endOffset);
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
/**
@@ -334,7 +340,10 @@ public template TextT(TStruct)
*/
public string getText(int startOffset, int endOffset)
{
- return Str.toString(atk_text_get_text(getTextStruct(), startOffset, endOffset));
+ auto retStr = atk_text_get_text(getTextStruct(), startOffset, endOffset);
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
/**
@@ -354,7 +363,10 @@ public template TextT(TStruct)
*/
public string getTextAfterOffset(int offset, AtkTextBoundary boundaryType, out int startOffset, out int endOffset)
{
- return Str.toString(atk_text_get_text_after_offset(getTextStruct(), offset, boundaryType, &startOffset, &endOffset));
+ auto retStr = atk_text_get_text_after_offset(getTextStruct(), offset, boundaryType, &startOffset, &endOffset);
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
/**
@@ -398,7 +410,10 @@ public template TextT(TStruct)
*/
public string getTextAtOffset(int offset, AtkTextBoundary boundaryType, out int startOffset, out int endOffset)
{
- return Str.toString(atk_text_get_text_at_offset(getTextStruct(), offset, boundaryType, &startOffset, &endOffset));
+ auto retStr = atk_text_get_text_at_offset(getTextStruct(), offset, boundaryType, &startOffset, &endOffset);
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
/**
@@ -418,7 +433,10 @@ public template TextT(TStruct)
*/
public string getTextBeforeOffset(int offset, AtkTextBoundary boundaryType, out int startOffset, out int endOffset)
{
- return Str.toString(atk_text_get_text_before_offset(getTextStruct(), offset, boundaryType, &startOffset, &endOffset));
+ auto retStr = atk_text_get_text_before_offset(getTextStruct(), offset, boundaryType, &startOffset, &endOffset);
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
/**
View
@@ -45,7 +45,10 @@ public import gtkc.gdktypes;
*/
public string name(GdkAtom atom)
{
- return Str.toString(gdk_atom_name(atom));
+ auto retStr = gdk_atom_name(atom);
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
/**
@@ -231,5 +234,8 @@ public int textPropertyToUtf8ListForDisplay(Display display, GdkAtom encoding, i
*/
public string utf8ToStringTarget(string str)
{
- return Str.toString(gdk_utf8_to_string_target(Str.toStringz(str)));
+ auto retStr = gdk_utf8_to_string_target(Str.toStringz(str));
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
View
@@ -242,7 +242,10 @@ public class Color
*/
public override string toString()
{
- return Str.toString(gdk_color_to_string(gdkColor));
+ auto retStr = gdk_color_to_string(gdkColor);
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
/**
View
@@ -132,7 +132,10 @@ public struct Gdk
*/
public static string getDisplay()
{
- return Str.toString(gdk_get_display());
+ auto retStr = gdk_get_display();
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
/**
View
@@ -265,6 +265,9 @@ public class RGBA
*/
public override string toString()
{
- return Str.toString(gdk_rgba_to_string(gdkRGBA));
+ auto retStr = gdk_rgba_to_string(gdkRGBA);
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
}
View
@@ -341,7 +341,10 @@ public class Screen : ObjectG
*/
public string getMonitorPlugName(int monitorNum)
{
- return Str.toString(gdk_screen_get_monitor_plug_name(gdkScreen, monitorNum));
+ auto retStr = gdk_screen_get_monitor_plug_name(gdkScreen, monitorNum);
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
/**
@@ -697,7 +700,10 @@ public class Screen : ObjectG
*/
public string makeDisplayName()
{
- return Str.toString(gdk_screen_make_display_name(gdkScreen));
+ auto retStr = gdk_screen_make_display_name(gdkScreen);
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
/**
@@ -105,7 +105,10 @@ public class PixbufFormat
*/
public string getDescription()
{
- return Str.toString(gdk_pixbuf_format_get_description(gdkPixbufFormat));
+ auto retStr = gdk_pixbuf_format_get_description(gdkPixbufFormat);
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
/**
@@ -119,7 +122,10 @@ public class PixbufFormat
*/
public string[] getExtensions()
{
- return Str.toStringArray(gdk_pixbuf_format_get_extensions(gdkPixbufFormat));
+ auto retStr = gdk_pixbuf_format_get_extensions(gdkPixbufFormat);
+
+ scope(exit) Str.freeStringArray(retStr);
+ return Str.toStringArray(retStr);
}
/**
@@ -134,7 +140,10 @@ public class PixbufFormat
*/
public string getLicense()
{
- return Str.toString(gdk_pixbuf_format_get_license(gdkPixbufFormat));
+ auto retStr = gdk_pixbuf_format_get_license(gdkPixbufFormat);
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
/**
@@ -147,7 +156,10 @@ public class PixbufFormat
*/
public string[] getMimeTypes()
{
- return Str.toStringArray(gdk_pixbuf_format_get_mime_types(gdkPixbufFormat));
+ auto retStr = gdk_pixbuf_format_get_mime_types(gdkPixbufFormat);
+
+ scope(exit) Str.freeStringArray(retStr);
+ return Str.toStringArray(retStr);
}
/**
@@ -159,7 +171,10 @@ public class PixbufFormat
*/
public string getName()
{
- return Str.toString(gdk_pixbuf_format_get_name(gdkPixbufFormat));
+ auto retStr = gdk_pixbuf_format_get_name(gdkPixbufFormat);
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
/**
View
@@ -379,7 +379,10 @@ public template ActionGroupT(TStruct)
*/
public string[] listActions()
{
- return Str.toStringArray(g_action_group_list_actions(getActionGroupStruct()));
+ auto retStr = g_action_group_list_actions(getActionGroupStruct());
+
+ scope(exit) Str.freeStringArray(retStr);
+ return Str.toStringArray(retStr);
}
/**
View
@@ -173,7 +173,10 @@ public template ActionT(TStruct)
*/
public static string printDetailedName(string actionName, Variant targetValue)
{
- return Str.toString(g_action_print_detailed_name(Str.toStringz(actionName), (targetValue is null) ? null : targetValue.getVariantStruct()));
+ auto retStr = g_action_print_detailed_name(Str.toStringz(actionName), (targetValue is null) ? null : targetValue.getVariantStruct());
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
/**
View
@@ -115,7 +115,10 @@ public class AppLaunchContext : ObjectG
*/
public string getDisplay(AppInfoIF info, ListG files)
{
- return Str.toString(g_app_launch_context_get_display(gAppLaunchContext, (info is null) ? null : info.getAppInfoStruct(), (files is null) ? null : files.getListGStruct()));
+ auto retStr = g_app_launch_context_get_display(gAppLaunchContext, (info is null) ? null : info.getAppInfoStruct(), (files is null) ? null : files.getListGStruct());
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
/**
@@ -131,7 +134,10 @@ public class AppLaunchContext : ObjectG
*/
public string[] getEnvironment()
{
- return Str.toStringArray(g_app_launch_context_get_environment(gAppLaunchContext));
+ auto retStr = g_app_launch_context_get_environment(gAppLaunchContext);
+
+ scope(exit) Str.freeStringArray(retStr);
+ return Str.toStringArray(retStr);
}
/**
@@ -150,7 +156,10 @@ public class AppLaunchContext : ObjectG
*/
public string getStartupNotifyId(AppInfoIF info, ListG files)
{
- return Str.toString(g_app_launch_context_get_startup_notify_id(gAppLaunchContext, (info is null) ? null : info.getAppInfoStruct(), (files is null) ? null : files.getListGStruct()));
+ auto retStr = g_app_launch_context_get_startup_notify_id(gAppLaunchContext, (info is null) ? null : info.getAppInfoStruct(), (files is null) ? null : files.getListGStruct());
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
/**
@@ -279,7 +279,10 @@ public class ApplicationCommandLine : ObjectG
{
int argc;
- return Str.toStringArray(g_application_command_line_get_arguments(gApplicationCommandLine, &argc));
+ auto retStr = g_application_command_line_get_arguments(gApplicationCommandLine, &argc);
+
+ scope(exit) Str.freeStringArray(retStr);
+ return Str.toStringArray(retStr, argc);
}
/**
View
@@ -81,7 +81,10 @@ public struct ContentType
*/
public static string fromMimeType(string mimeType)
{
- return Str.toString(g_content_type_from_mime_type(Str.toStringz(mimeType)));
+ auto retStr = g_content_type_from_mime_type(Str.toStringz(mimeType));
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
/**
@@ -95,7 +98,10 @@ public struct ContentType
*/
public static string getDescription(string type)
{
- return Str.toString(g_content_type_get_description(Str.toStringz(type)));
+ auto retStr = g_content_type_get_description(Str.toStringz(type));
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
/**
@@ -115,7 +121,10 @@ public struct ContentType
*/
public static string getGenericIconName(string type)
{
- return Str.toString(g_content_type_get_generic_icon_name(Str.toStringz(type)));
+ auto retStr = g_content_type_get_generic_icon_name(Str.toStringz(type));
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
/**
@@ -150,7 +159,10 @@ public struct ContentType
*/
public static string getMimeType(string type)
{
- return Str.toString(g_content_type_get_mime_type(Str.toStringz(type)));
+ auto retStr = g_content_type_get_mime_type(Str.toStringz(type));
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
/**
@@ -196,11 +208,12 @@ public struct ContentType
{
int outresultUncertain;
- auto p = g_content_type_guess(Str.toStringz(filename), data.ptr, cast(size_t)data.length, &outresultUncertain);
+ auto retStr = g_content_type_guess(Str.toStringz(filename), data.ptr, cast(size_t)data.length, &outresultUncertain);
resultUncertain = (outresultUncertain == 1);
- return Str.toString(p);
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
/**
@@ -227,7 +240,10 @@ public struct ContentType
*/
public static string[] guessForTree(FileIF root)
{
- return Str.toStringArray(g_content_type_guess_for_tree((root is null) ? null : root.getFileStruct()));
+ auto retStr = g_content_type_guess_for_tree((root is null) ? null : root.getFileStruct());
+
+ scope(exit) Str.freeStringArray(retStr);
+ return Str.toStringArray(retStr);
}
/**
View
@@ -299,6 +299,9 @@ public class Credentials : ObjectG
*/
public override string toString()
{
- return Str.toString(g_credentials_to_string(gCredentials));
+ auto retStr = g_credentials_to_string(gCredentials);
+
+ scope(exit) Str.freeString(retStr);
+ return Str.toString(retStr);
}
}
Oops, something went wrong.

0 comments on commit 83cab4a

Please sign in to comment.