From c2f5017b07c6a3c68235340d6804ca29fb96c57f Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Wed, 16 Oct 2019 08:56:58 +0200 Subject: Update glib annotations --- gir/glib-2.0.c | 334 ++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 272 insertions(+), 62 deletions(-) (limited to 'gir/glib-2.0.c') diff --git a/gir/glib-2.0.c b/gir/glib-2.0.c index 2ab32b8a..9d555925 100644 --- a/gir/glib-2.0.c +++ b/gir/glib-2.0.c @@ -3223,7 +3223,7 @@ * @major: major version to check against * @minor: minor version to check against * - * Expands to a a check for a compiler with __GNUC__ defined and a version + * Expands to a check for a compiler with __GNUC__ defined and a version * greater than or equal to the major and minor numbers provided. For example, * the following would only match on compilers such as GCC 4.8 or newer. * @@ -5595,6 +5595,13 @@ * function (the file being opened, or whatever - though in the * g_file_get_contents() case, the @message already contains a filename). * + * Note, however, that many error messages are too technical to display to the + * user in an application, so prefer to use g_error_matches() to categorize errors + * from called functions, and build an appropriate error message for the context + * within your application. Error messages from a #GError are more appropriate + * to be printed in system logs or on the command line. They are typically + * translated. + * * When implementing a function that can report errors, the basic * tool is g_set_error(). Typically, if a fatal error occurs you * want to g_set_error(), then return immediately. g_set_error() @@ -6457,7 +6464,7 @@ * To remove a key and value, use g_hash_table_remove(). * * To call a function for each key and value pair use - * g_hash_table_foreach() or use a iterator to iterate over the + * g_hash_table_foreach() or use an iterator to iterate over the * key/value pairs in the hash table, see #GHashTableIter. * * To destroy a #GHashTable use g_hash_table_destroy(). @@ -7075,6 +7082,9 @@ * new with delete and new[] with delete[]. Otherwise bad things can happen, * since these allocators may use different memory pools (and new/delete call * constructors and destructors). + * + * Since GLib 2.46 g_malloc() is hardcoded to always use the system malloc + * implementation. */ @@ -8162,7 +8172,6 @@ * setlocale (LC_ALL, ""); * * g_test_init (&argc, &argv, NULL); - * g_test_bug_base ("http://bugzilla.gnome.org/show_bug.cgi?id="); * * // Define the tests. * g_test_add ("/my-object/test1", MyObjectFixture, "some-user-data", @@ -9159,6 +9168,37 @@ */ +/** + * g_array_steal: + * @array: a #GArray. + * @len: (optional) (out caller-allocates): pointer to retrieve the number of + * elements of the original array + * + * Frees the data in the array and resets the size to zero, while + * the underlying array is preserved for use elsewhere and returned + * to the caller. + * + * If the array was created with the @zero_terminate property + * set to %TRUE, the returned data is zero terminated too. + * + * If array elements contain dynamically-allocated memory, + * the array elements should also be freed by the caller. + * + * A short example of use: + * |[ + * ... + * gpointer data; + * gsize data_len; + * data = g_array_steal (some_array, &data_len); + * ... + * ]| + * + * Returns: (transfer full): the element data, which should be + * freed using g_free(). + * Since: 2.64 + */ + + /** * g_array_unref: * @array: A #GArray @@ -9727,7 +9767,7 @@ /** * g_assert_cmpfloat: - * @n1: an floating point number + * @n1: a floating point number * @cmp: The comparison operator to use. * One of `==`, `!=`, `<`, `>`, `<=`, `>=`. * @n2: another floating point number @@ -9745,7 +9785,7 @@ /** * g_assert_cmpfloat_with_epsilon: - * @n1: an floating point number + * @n1: a floating point number * @n2: another floating point number * @epsilon: a numeric value that expresses the expected tolerance * between @n1 and @n2 @@ -9797,9 +9837,9 @@ /** * g_assert_cmpmem: - * @m1: pointer to a buffer + * @m1: (nullable): pointer to a buffer * @l1: length of @m1 - * @m2: pointer to another buffer + * @m2: (nullable): pointer to another buffer * @l2: length of @m2 * * Debugging macro to compare memory regions. If the comparison fails, @@ -9811,6 +9851,8 @@ * The advantage of this macro is that it can produce a message that * includes the actual values of @l1 and @l2. * + * @m1 may be %NULL if (and only if) @l1 is zero; similarly for @m2 and @l2. + * * |[ * g_assert_cmpmem (buf->data, buf->len, expected, sizeof (expected)); * ]| @@ -12456,6 +12498,22 @@ */ +/** + * g_byte_array_steal: + * @array: a #GByteArray. + * @len: (optional) (out caller-allocates): pointer to retrieve the number of + * elements of the original array + * + * Frees the data in the array and resets the size to zero, while + * the underlying array is preserved for use elsewhere and returned + * to the caller. + * + * Returns: (transfer full): the element data, which should be + * freed using g_free(). + * Since: 2.64 + */ + + /** * g_byte_array_unref: * @array: A #GByteArray @@ -12799,7 +12857,7 @@ * g_checksum_get_string: * @checksum: a #GChecksum * - * Gets the digest as an hexadecimal string. + * Gets the digest as a hexadecimal string. * * Once this function has been called the #GChecksum can no longer be * updated with g_checksum_update(). @@ -15106,9 +15164,13 @@ * * Creates a #GDateTime corresponding to the given * [ISO 8601 formatted string](https://en.wikipedia.org/wiki/ISO_8601) - * @text. ISO 8601 strings of the form