mirror of https://github.com/GNOME/gimp.git
libgimpbase: fix/improve docs/annotations.
Our GimpStringArray is so weird. We are obviously expecting it to be NULL-terminated since, when we duplicate the data, we add one value. Yet we were not checking that the stored data was NULL-terminated, in particular when the string array is created with static data (in which case, we use the input data as-is, without re-allocating). Note that this doesn't fix the type mismatch Gimp.StringArray vs Gimp.Array when introspecting.
This commit is contained in:
parent
aa6a1d369c
commit
d999248d70
|
@ -1321,13 +1321,19 @@ gimp_value_take_float_array (GValue *value,
|
|||
|
||||
/**
|
||||
* gimp_string_array_new:
|
||||
* @data: (array length=length): an array of strings.
|
||||
* @data: (array length=length) (transfer none): an array of strings.
|
||||
* @length: the length of @data.
|
||||
* @static_data: whether the strings in @data are static strings rather
|
||||
* than allocated.
|
||||
*
|
||||
* Creates a new #GimpArray containing string data, of size @length.
|
||||
*
|
||||
* If @static_data is %TRUE, @data is used as-is and should also be
|
||||
* NULL-terminated.
|
||||
*
|
||||
* If @static_data is %FALSE, the string and array will be re-allocated,
|
||||
* hence you are expected to free your input data after.
|
||||
*
|
||||
* Returns: (transfer full) (type GimpArray): a new #GimpArray.
|
||||
*/
|
||||
GimpArray *
|
||||
|
@ -1339,6 +1345,8 @@ gimp_string_array_new (const gchar **data,
|
|||
|
||||
g_return_val_if_fail ((data == NULL && length == 0) ||
|
||||
(data != NULL && length > 0), NULL);
|
||||
g_return_val_if_fail (! static_data || ! data ||
|
||||
g_strv_length (data) == length, NULL);
|
||||
|
||||
array = g_slice_new0 (GimpArray);
|
||||
|
||||
|
@ -1561,7 +1569,7 @@ gimp_value_get_string_array (const GValue *value)
|
|||
* gimp_value_dup_string_array:
|
||||
* @value: a #GValue holding a string #GimpArray.
|
||||
*
|
||||
* Returns: (transfer none) (array zero-terminated=1): a deep copy of the array of strings.
|
||||
* Returns: (transfer full) (array zero-terminated=1): a deep copy of the array of strings.
|
||||
*/
|
||||
gchar **
|
||||
gimp_value_dup_string_array (const GValue *value)
|
||||
|
|
Loading…
Reference in New Issue