summaryrefslogtreecommitdiff
path: root/docs/reference/glib
Commit message (Collapse)AuthorAgeFilesLines
...
* | | compiling.xml: Don't recommend backticksUtkarsh Singh2021-06-091-6/+6
| |/ |/|
* | docs: Wrap a code example more tightly to reduce minimum page widthPhilip Withnall2021-06-031-2/+5
| | | | | | | | | | | | | | | | | | Otherwise the page has a horizontal scrollbar in Devhelp on some machines. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Fixes: #2414
* | Add g_prefix_error_literal()Dan Williams2021-05-281-0/+1
| | | | | | | | | | | | | | | | Because sometimes you don't want a lone "%s", and you don't want the compiler yelling at you about format strings that don't have any format in them. Closes #663
* | gstrvbuilder: add addv and add_many to the APIalex-tee2021-05-261-0/+2
|/
* Add the G_OPTION_ENTRY_NULL macro to properly initialize GOptionEntry arraysEmmanuel Fleury2021-05-131-0/+1
|
* docs: Standardize spelling of serializ*Geyslan G. Bem2021-05-071-3/+3
| | | | | | Changes serialis* to serializ* as proposed in #2399. Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
* gmacros: Add __ to noinline to prevent conflict with macro in pixmanRobin Verdenal-Tallieux2021-05-031-1/+1
| | | | Fixes: #2388
* gpattern: Move match and match_string functions into GPatternSpecMarco Trevisan (Treviño)2021-04-271-0/+2
| | | | | | This allows introspection to properly handle them as GPatternSpec methods, as per this deprecate g_pattern_match() and g_pattern_match_string() functions.
* gpattern: Implement copy functionMarco Trevisan (Treviño)2021-04-271-0/+1
| | | | | Add copy ability for pattern spec, so that it can be used as a boxed type.
* gmacros.h: use g_macro__has_attribute() where possibleAleksandr Mezin2021-04-161-0/+15
| | | | | | | | | Fall back to compiler version checks only when `__has_attribute()` is not available. clang-cl doesn't define `__GNU__`, but still accepts attributes. This change gets rid of a lot of warnings when building GLib with clang-cl. For GCC and non-cl Clang nothing should change.
* glib-sections.txt: Add g_macro__has_extension in private sectionclang-cl-improvementsChun-wei Fan2021-03-311-0/+1
| | | | This should satisfy the documentation build check.
* gtree: Make g_tree_remove_all() publicliuyangming2021-03-231-0/+1
| | | | | g_tree_remove_all is useful and the corresponding function in GHashTable is exposed, so make this function public is meaningful.
* gmain: Add g_steal_fd() to APISimon McVittie2021-03-221-0/+3
| | | | | | | This is basically glnx_steal_fd() from libglnx. We already had two private implementations of it in GLib. Signed-off-by: Simon McVittie <smcv@collabora.com>
* gversionmacros: Add version macros for GLib 2.70Simon McVittie2021-03-182-0/+18
| | | | Signed-off-by: Simon McVittie <smcv@collabora.com>
* gspawn: Add new g_spawn_async_with_pipes_and_fds() APIPhilip Withnall2021-02-161-0/+1
| | | | | | | | | This is a simple wrapper around the new source/target FD mapping functionality in `fork_exec()`. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Helps: #2097
* string: Add find and replace functionJoshua Lee2021-02-091-0/+1
| | | | | | | | | This adds g_string_replace(), a function that replaces instances of one string with another in a GString. It allows the caller to specify the maximum number of replacements to perform, and returns the number of replacements performed to the caller. Fixes: #225
* gstrfuncs: Add g_memdup2() functionPhilip Withnall2021-02-041-0/+1
| | | | | | | | | | | | | | | | | | | | This will replace the existing `g_memdup()` function, which has an unavoidable security flaw of taking its `byte_size` argument as a `guint` rather than as a `gsize`. Most callers will expect it to be a `gsize`, and may pass in large values which could silently be truncated, resulting in an undersize allocation compared to what the caller expects. This could lead to a classic buffer overflow vulnerability for many callers of `g_memdup()`. `g_memdup2()`, in comparison, takes its `byte_size` as a `gsize`. Spotted by Kevin Backhouse of GHSL. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Helps: GHSL-2021-045 Helps: #2319
* glib_typeof: It is an API break that should be opt-inXavier Claessens2021-01-271-0/+1
| | | | | | | | | | | | | | | | That changes the return type of functions like g_object_ref() that can break C++ applications like Webkit. Note that it is not an ABI break. It must thus be opt-in the same way we did when adding this to g_object_ref() for GNU C compilers in the first place. Unfortunately it cannot be done directly in gmacros.h because GLIB_VERSION_2_68 is not defined there, and gversionmacros.h cannot be included there because there is some strict ordering in which those headers must be included. This means that applications that does not define GLIB_VERSION_MIN_REQUIRED will still get an API break, so we encourage them to declare their minimum requirement to avoir such issues in the future too.
* gtestutils: Add g_test_get_path() APIJonas Ådahl2021-01-251-0/+1
| | | | | | | | I found myself wanting to know the test that is currently being run, where e.g. __func__ would be inconvenient to use, because e.g. the place the string was needed was not in the test case function. Using __func__ also relies on the test function itself containing the whole path, while loosing the "/" information that is part of the test path.
* docs: Add documentation for GLIB_VERSION_CUR_STABLE and PREV_STABLEPhilip Withnall2021-01-191-0/+2
| | | | | | It was missing. Oh no! Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
* gerror: Add support for extended errorsKrzesimir Nowak2021-01-061-0/+7
| | | | | | This commit adds a G_DEFINE_EXTENDED_ERROR macro and g_error_domain_register() functions to register extended error domains.
* Adding macros G_NORETURN and G_NORETURN_FUNCPTREmmanuel Fleury2020-11-251-0/+2
| | | | | | This macro is borrowed from the gnulib project in the 'noreturn.h' file. Fixes: #994
* Merge branch '553-tz-errors' into 'master'Sebastian Dröge2020-11-221-0/+1
|\ | | | | | | | | | | | | gtimezone: Add new constructor which can report errors Closes #553 See merge request GNOME/glib!1760
| * gtimezone: Add new constructor which can report errorsPhilip Withnall2020-11-181-0/+1
| | | | | | | | | | | | | | | | | | Add a new variant of `g_time_zone_new()` which returns `NULL` on failure to load a timezone, rather than silently returning UTC. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Fixes: #553
* | docs: Clarify the meaning of --buildtype=plain a littlePhilip Withnall2020-11-181-0/+6
|/ | | | | | Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Fixes: #1833
* gtestutils: Add g_assert_cmpstrv()Niels De Graef2020-11-141-0/+1
| | | | | | | Add a test util function that helps asserting two string arrays are the same, and which adds some useful information if they're not. Fixes: #2015
* gio: Fix various typos of the name ‘D-Bus’Philip Withnall2020-10-261-2/+2
| | | | | | This introduces no functional changes. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
* Merge branch 'typeof' into 'master'Philip Withnall2020-10-151-1/+1
|\ | | | | | | | | Use C++11 decltype where possible See merge request GNOME/glib!1575
| * Replace __typeof__ with glib_typeof macroXavier Claessens2020-10-141-1/+1
| | | | | | | | | | | | | | g_has_typeof macro is wrongly in the public g_ namespace, internaly symbols are usually in the glib_ namespace. This will also allow to define glib_typeof differently on non-GNUC compilers (e.g. c++11 decltype).
* | gstrvbuilder: Add a new object to make NULL-terminated string arrays.Robert Ancell2020-10-141-0/+6
|/ | | | | | | GLib uses NULL-terminated string arrays (GStrv) in a number of places, however these are quite hard to construct in C when the number of elements is not known in advance. GStrvBuilder wraps GPtrArray to make these easy to create with type safety and does the memory management for you.
* gmessages: Expose our default filtering as APISimon McVittie2020-10-071-0/+1
| | | | | | | | | This allows programs that want to change how log messages are printed, such as gnome-terminal (gnome-terminal#42) and Flatpak, to override the log-writer or the legacy log-handler without having to reimplement the G_MESSAGES_DEBUG filtering logic. Signed-off-by: Simon McVittie <smcv@collabora.com>
* gmessages: Add API to move info and debug messages to stderrSimon McVittie2020-10-071-0/+1
| | | | | | | | | | | | | | | | | | | | | GLib code normally prints info and debug messages to stdout, but that interferes with programs that are documented to produce machine-readable output such as JSON or XML on stdout. In particular, if such a program uses a GLib-based library, setting G_MESSAGES_DEBUG will typically result in that library's debug messages going to the program's stdout and corrupting the machine-readable output. Unix programs can avoid this by using dup2() to move the original stdout to another fd, then dup2() again to make the new stdout a copy of stderr, but it's easier if we provide a way to not write debug messages to stdout in the first place. Calling g_log_writer_default_set_use_stderr (TRUE) results in behaviour resembling Python's logging.basicConfig(), with all diagnostics going to stderr. Suggested by Allison Karlitskaya on glib#2087. Signed-off-by: Simon McVittie <smcv@collabora.com>
* GTree: add an ability to iterate over a tree and a node-based APIMaciej S. Szmigiero2020-10-061-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The basic API that this commit adds allows in-order iterating over a GTree. For this the following API were implemented or exported: 1) Returning the first or the last node in the tree, 2) Taking a pointer to a node in the tree and returning the previous or the next in-order node, 3) Allowing to do a binary search for a particular key value and returning the pointer to its node, 4) Returning the newly inserted or set node from both insert and replace functions, so this node is immediately available and does not have to be looked up, 5) Traversing the tree in-order providing a node pointer to the caller-provided traversal function. Most of the above functions were already present in the code, but they returned the value that is stored at a particular node instead of the pointer to the node itself. So most of the code for these new API calls is shared with these existing ones, just adapted to return the pointer to the node. Additionally, the so called "lower bound" and "upper bound" operations were implemented. The first one returns the first element that is greater than or equal to the searched key, while the second returns the first element that is strictly greater than the searched key. Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
* gversionmacros: Add version macros for GLib 2.68Philip Withnall2020-10-012-0/+18
| | | | Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
* uri: add GUriParamsIterMarc-André Lureau2020-08-041-0/+3
| | | | | See also: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1328#note_863735
* gfileutils: Add g_file_set_contents_full() and GFileSetContentsFlagsPhilip Withnall2020-07-261-0/+2
| | | | | | | | | | | | | This is a new version of the g_file_set_contents() API which will allow its safety to be controlled by some flags, allowing the user to choose their preferred tradeoff between safety (`fsync()` calls) and speed. Currently, the flags do nothing and the new API behaves like the old API. This will change in the following commits. Signed-off-by: Philip Withnall <withnall@endlessm.com> Helps: #1302
* Merge branch 'uri-parse-params' into 'master'Philip Withnall2020-07-081-0/+1
|\ | | | | | | | | A few g_uri_parse_params() improvements See merge request GNOME/glib!1557
| * uri: modify g_uri_parse_params() to take flagsMarc-André Lureau2020-07-071-0/+1
| | | | | | | | | | | | | | This will allow to further enhance the parsing, without breaking API, and also makes argument on call side a bit clearer than just TRUE/FALSE. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* | gtrace: Add sysprof tracing support infrastructurePhilip Withnall2020-07-071-0/+1
|/ | | | | | | | | | | | | | | | | | | Add some internal wrappers around sysprof tracing, so that it can be used throughout GLib without exposing all the details of sysprof internally. This adds an optional dependency on `libsysprof-capture-4`. sysprof support is disabled without it. This depends on the GLib dependency of `libsysprof-capture` being dropped in https://gitlab.gnome.org/GNOME/sysprof/-/merge_requests/30, which has bumped the soname of `libsysprof-capture` and added subproject support. The next few commits will add marks that trace out each `GMainContext` iteration and each `GSource` `check`/`prepare`/`dispatch` call. Signed-off-by: Philip Withnall <withnall@endlessm.com>
* guri: new URI parsing and generating functionsDan Winship2020-06-252-3/+47
| | | | | | | | | | | | Add a set of new URI parsing and generating functions, including a new parsed-URI type GUri. Move all the code from gurifuncs.c into guri.c, reimplementing some of those functions (and g_string_append_uri_encoded()) in terms of the new code. Fixes: https://gitlab.gnome.org/GNOME/glib/issues/110 Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* tree: Fix various typos and outdated terminologyPhilip Withnall2020-06-125-9/+9
| | | | | | | | | | | | | | | | | | | | | | | This was mostly machine generated with the following command: ``` codespell \ --builtin clear,rare,usage \ --skip './po/*' --skip './.git/*' --skip './NEWS*' \ --write-changes . ``` using the latest git version of `codespell` as per [these instructions](https://github.com/codespell-project/codespell#user-content-updating). Then I manually checked each change using `git add -p`, made a few manual fixups and dropped a load of incorrect changes. There are still some outdated or loaded terms used in GLib, mostly to do with git branch terminology. They will need to be changed later as part of a wider migration of git terminology. If I’ve missed anything, please file an issue! Signed-off-by: Philip Withnall <withnall@endlessm.com>
* gbookmarkfile: Add Y2038-proof APIs to GBookmarkFilePhilip Withnall2020-05-281-0/+8
| | | | | | | | | | | | These are alternatives to the existing `time_t`-based APIs, which will soon be deprecated due to `time_t` only being Y2038-safe on 64-bit systems. The new APIs take a GDateTime instead. Signed-off-by: Philip Withnall <withnall@endlessm.com> Helps: #1931
* Revert "Revert "glib: annotate static inline functions with G_AVAILABLE-type ↵Philip Withnall2020-05-151-0/+6
| | | | | | | | | | | | macros"" This reverts commit c0146be3a4e0cda7a23d7fd54cc60a0bc7ba7f7a. The revert was originally added because the original change broke gnome-build-meta. Now that the problem has been diagnosed, the original commit can be fixed — see the commit which follows this one. See: !1487
* gtestutils: Add a new g_assert_no_errno() test macroPhilip Withnall2020-03-041-0/+1
| | | | | | | | | | | | This is for use in testing POSIX-style functions like `rmdir()`, which return an integer < 0 on failure, and return their error information in `errno`. The new macro prints `errno` and `g_strerror (errno)` on failure. Includes a unit test. Signed-off-by: Philip Withnall <withnall@endlessm.com>
* gversionmacros: Add version macros for GLib 2.66Philip Withnall2020-03-042-0/+17
| | | | Signed-off-by: Philip Withnall <withnall@endlessm.com>
* doc: Run gtkdoc-check with unit testsXavier Claessens2020-01-291-1/+2
| | | | | | This has the side effect of always rebuilding the doc at each build when gtk_doc option is enabled (not by default). Most importantly, this will enable doc check on our CI.
* docs: tag enclose 'all' and 'help' valuesNelson Benítez León2020-01-291-4/+4
| | | | | | | so they are not confused as being normal text. Seen at: https://developer.gnome.org/glib/stable/glib-running.html
* Add and use G_SIZEOF_MEMBER() macroMarc-André Lureau2020-01-211-0/+1
| | | | | | A convenient macro present in the Linux kernel, named FIELD_SIZE() there. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* docs: Add g_source_set_dispose_function() to documentationPhilip Withnall2019-12-161-0/+2
| | | | Signed-off-by: Philip Withnall <withnall@endlessm.com>
* Merge branch 'thread-safe-getpwnam' into 'master'Emmanuele Bassi2019-11-271-0/+3
|\ | | | | | | | | | | | | glocalvfs: Use thread-safe getpwnam_r() rather than getpwnam() Closes #1687 See merge request GNOME/glib!681