summaryrefslogtreecommitdiff
path: root/girepository/giconstantinfo.c
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2011-10-05 16:31:43 -0400
committerJasper St. Pierre <jstpierre@mecheye.net>2011-10-05 16:46:33 -0400
commit8e970f46b8525396009d4d833a1f1cdacd3df6a1 (patch)
tree3b33e27ba1d2cca48d0ed7b259fca66738daee4c /girepository/giconstantinfo.c
parent25fb1964cbf603a457308a3ecb9ed177262763ef (diff)
downloadgobject-introspection-8e970f46b8525396009d4d833a1f1cdacd3df6a1.tar.gz
giconstantinfo: Add API to fix memory leak
https://bugzilla.gnome.org/show_bug.cgi?id=654069
Diffstat (limited to 'girepository/giconstantinfo.c')
-rw-r--r--girepository/giconstantinfo.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/girepository/giconstantinfo.c b/girepository/giconstantinfo.c
index c0823030..2c3cc292 100644
--- a/girepository/giconstantinfo.c
+++ b/girepository/giconstantinfo.c
@@ -69,6 +69,35 @@ g_constant_info_get_type (GIConstantInfo *info)
memcpy((dest_addr), (src_addr), sizeof(type))
/**
+ * g_constant_info_free_value: (skip)
+ * @info: a #GIConstantInfo
+ * @value: the argument
+ *
+ * Free the value returned from g_constant_info_get_value().
+ *
+ * Since: 1.30.1
+ */
+void
+g_constant_info_free_value (GIConstantInfo *info,
+ GIArgument *value)
+{
+ GIRealInfo *rinfo = (GIRealInfo *)info;
+ ConstantBlob *blob;
+
+ g_return_if_fail (info != NULL);
+ g_return_if_fail (GI_IS_CONSTANT_INFO (info));
+
+ blob = (ConstantBlob *)&rinfo->typelib->data[rinfo->offset];
+
+ /* FIXME non-basic types ? */
+ if (blob->type.flags.reserved == 0 && blob->type.flags.reserved2 == 0)
+ {
+ if (blob->type.flags.pointer)
+ g_free (value->v_pointer);
+ }
+}
+
+/**
* g_constant_info_get_value: (skip)
* @info: a #GIConstantInfo
* @value: (out): an argument
@@ -76,6 +105,7 @@ g_constant_info_get_type (GIConstantInfo *info)
* Obtain the value associated with the #GIConstantInfo and store it in the
* @value parameter. @argument needs to be allocated before passing it in.
* The size of the constant value stored in @argument will be returned.
+ * Free the value with g_constant_info_free_value().
*
* Returns: size of the constant
*/