mirror of https://github.com/GNOME/gimp.git
libgimpbase: improve gimp_parasite_get_data().
Allow @num_bytes to be nullable, but add text in the documentation that this is only useful when you want to check if there is contents. Also make @num_bytes into a guint32, and finally set it to 0 when there is no parasite.
This commit is contained in:
parent
3303f9182e
commit
443b738e61
|
@ -447,23 +447,33 @@ gimp_parasite_data_size (const GimpParasite *parasite)
|
||||||
/**
|
/**
|
||||||
* gimp_parasite_get_data:
|
* gimp_parasite_get_data:
|
||||||
* @parasite: a #GimpParasite
|
* @parasite: a #GimpParasite
|
||||||
* @num_bytes: (out): size of the returned data.
|
* @num_bytes: (out) (nullable): size of the returned data.
|
||||||
*
|
*
|
||||||
* Gets the parasite's data. It may not necessarily be text, nor is it
|
* Gets the parasite's data. It may not necessarily be text, nor is it
|
||||||
* guaranteed to be %NULL-terminated. It is your responsibility to know
|
* guaranteed to be %NULL-terminated. It is your responsibility to know
|
||||||
* how to deal with this data.
|
* how to deal with this data.
|
||||||
|
* Even when you expect a nul-terminated string, it is advised not to
|
||||||
|
* assume the returned data to be, as parasites can be edited by third
|
||||||
|
* party scripts. You may end up reading out-of-bounds data. So you
|
||||||
|
* should only ignore @num_bytes when you all you care about is checking
|
||||||
|
* if the parasite has contents.
|
||||||
*
|
*
|
||||||
* Returns: (array length=num_bytes) (element-type char): parasite's data.
|
* Returns: (array length=num_bytes) (element-type char): parasite's data.
|
||||||
*/
|
*/
|
||||||
gconstpointer
|
gconstpointer
|
||||||
gimp_parasite_get_data (const GimpParasite *parasite,
|
gimp_parasite_get_data (const GimpParasite *parasite,
|
||||||
gint *num_bytes)
|
guint32 *num_bytes)
|
||||||
{
|
{
|
||||||
if (parasite)
|
if (parasite)
|
||||||
{
|
{
|
||||||
*num_bytes = parasite->size;
|
if (num_bytes)
|
||||||
|
*num_bytes = parasite->size;
|
||||||
|
|
||||||
return parasite->data;
|
return parasite->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (num_bytes)
|
||||||
|
*num_bytes = 0;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ gconstpointer gimp_parasite_data (const GimpParasite *parasite);
|
||||||
glong gimp_parasite_data_size (const GimpParasite *parasite);
|
glong gimp_parasite_data_size (const GimpParasite *parasite);
|
||||||
|
|
||||||
gconstpointer gimp_parasite_get_data (const GimpParasite *parasite,
|
gconstpointer gimp_parasite_get_data (const GimpParasite *parasite,
|
||||||
gint *num_bytes);
|
guint32 *num_bytes);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue