mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-23 15:49:16 +02:00
giconstantinfo: Add API to fix memory leak
https://bugzilla.gnome.org/show_bug.cgi?id=654069
This commit is contained in:
parent
11cf4c56f3
commit
b75e788785
@ -68,6 +68,35 @@ g_constant_info_get_type (GIConstantInfo *info)
|
|||||||
#define DO_ALIGNED_COPY(dest_addr, src_addr, type) \
|
#define DO_ALIGNED_COPY(dest_addr, src_addr, type) \
|
||||||
memcpy((dest_addr), (src_addr), sizeof(type))
|
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)
|
* g_constant_info_get_value: (skip)
|
||||||
* @info: a #GIConstantInfo
|
* @info: a #GIConstantInfo
|
||||||
@ -76,6 +105,7 @@ g_constant_info_get_type (GIConstantInfo *info)
|
|||||||
* Obtain the value associated with the #GIConstantInfo and store it in the
|
* Obtain the value associated with the #GIConstantInfo and store it in the
|
||||||
* @value parameter. @argument needs to be allocated before passing it in.
|
* @value parameter. @argument needs to be allocated before passing it in.
|
||||||
* The size of the constant value stored in @argument will be returned.
|
* 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
|
* Returns: size of the constant
|
||||||
*/
|
*/
|
||||||
|
@ -34,6 +34,8 @@ G_BEGIN_DECLS
|
|||||||
(g_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_CONSTANT)
|
(g_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_CONSTANT)
|
||||||
|
|
||||||
GITypeInfo * g_constant_info_get_type (GIConstantInfo *info);
|
GITypeInfo * g_constant_info_get_type (GIConstantInfo *info);
|
||||||
|
void g_constant_info_free_value(GIConstantInfo *info,
|
||||||
|
GIArgument *value);
|
||||||
gint g_constant_info_get_value(GIConstantInfo *info,
|
gint g_constant_info_get_value(GIConstantInfo *info,
|
||||||
GIArgument *value);
|
GIArgument *value);
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user