Commit Graph

26859 Commits

Author SHA1 Message Date
Marco Trevisan
5c34cf3dbb Merge branch 'ebassi/no-preallocs' into 'main'
Remove n_preallocs field from InstanceData

See merge request GNOME/glib!3256
2023-02-06 13:33:16 +00:00
Emmanuele Bassi
8f92f742b9 Remove n_preallocs field from InstanceData
The GTypeInfo.n_preallocs field has been ignored since GLib 2.10, but it
hasn't been removed from the internal instance data representation.
2023-02-04 16:55:30 +01:00
Michael Catanzaro
35170735de Merge branch 'force-non-null-gslice-free' into 'main'
gslice: Do not try to memset-0 NULL a pointer

Closes #2908

See merge request GNOME/glib!3253
2023-02-03 23:19:43 +00:00
Marco Trevisan (Treviño)
893b86b939 gslice: Mark memory arguments and return values as nullable when it's the case
GSlice can handle NULL arguments or return NULL values, but we did not
properly mark them all the times.
2023-02-03 16:28:51 +01:00
Marco Trevisan (Treviño)
6af6f3eb9b gslice: Do not try to memset-0 NULL a pointer
According to the docs, g_slice_free1() is supposed to do nothing if
@mem_block is NULL, but we still try to zero it in case we're using
g_mem_gc_friendly.

So avoid this case.

Closes: #2908
2023-02-03 16:28:37 +01:00
Marco Trevisan
95cbff0fd2 Merge branch 'free-sized' into 'main'
gmem: Add g_free_sized() and g_aligned_free_sized()

See merge request GNOME/glib!3231
2023-02-03 10:01:35 +00:00
Philip Withnall
548d917f35 Merge branch 'gcc13-warning-fix' into 'main'
timezone: Fix a compiler warning

See merge request GNOME/glib!3248
2023-02-03 08:02:57 +00:00
Philip Withnall
b3b459107a Merge branch 'fix-inline-warnings' into 'main'
gstring: Avoid warnings from inline functions

See merge request GNOME/glib!3249
2023-02-03 07:57:40 +00:00
Matthias Clasen
d9f8d73be2 gstring: Avoid warnings from inline functions
The current code for g_string_append_c_inline generates
warnings when used, with -Wnull-dereference. Avoid that.
2023-02-03 00:36:53 +00:00
Matthias Clasen
cbb2ca8c4a timezone: Fix a compiler warning
gcc 13 complains that last_explicit_transition_time
may be used uninitialized.
2023-02-03 00:36:21 +00:00
Philip Withnall
964ecf5ec9 Merge branch 'wip/pwithnall/freebsd-ci-again' into 'main'
ci: Temporarily only run the FreeBSD 13 CI on a schedule

See merge request GNOME/glib!3250
2023-02-03 00:30:14 +00:00
Philip Withnall
163ebdc6c2 ci: Temporarily only run the FreeBSD 13 CI on a schedule
Rather than on every commit, because the CI runner is currently broken:
https://gitlab.gnome.org/Infrastructure/GitLab/-/issues/601.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-02-03 00:13:53 +00:00
Philip Withnall
622e1d8c83 Merge branch 'wip/ernestask/converter-null-out' into 'main'
gio: converter: Forbid null out arguments

See merge request GNOME/glib!3245
2023-02-02 22:39:57 +00:00
Ernestas Kulik
e0976efee9 gio: converter: Forbid null out arguments
Currently, inbuf_size and outbuf_size are not documented as not
nullable, but they are expected to be so, which might lead to unexpected
crashes. Moreover, outbuf itself is also expected to not be null, so
this commit adds the appropriate GI annotations and early returns on
failed preconditions.
2023-02-02 21:25:56 +02:00
Ekaterine Papava
f6c6171c08 Update Georgian translation 2023-02-02 18:55:40 +00:00
Philip Withnall
97ebd794a7 gslice: Use g_free_sized() instead of g_free()
If libc supports `free_sized()`, this could mean that freeing slices is
a bit more performant. If not, it falls back to using `free()`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-02-02 12:30:59 +00:00
Philip Withnall
329843f682 gmem: Add g_free_sized() and g_aligned_free_sized()
These wrap `free_sized()` and `free_aligned_sized()`, which are present
in C23[1]. This means that user code can start to use them without checking
for C23 support everywhere first.

It also means we can use them internally in GSlice to get a bit of
performance for the code which still uses it.

See https://en.cppreference.com/w/c/memory/free_aligned_sized and
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2699.htm.

[1]: Specifically, section 7.24.3.4 of the latest C23 draft at
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3088.pdf.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-02-02 12:30:59 +00:00
Fran Dieguez
c88e9e1f5c Update Galician translation 2023-02-01 21:46:54 +00:00
Marco Trevisan
fe2de360de Merge branch 'cxx-leak' into 'main'
tests: Fix a minor leak in the cxx string append tests

See merge request GNOME/glib!3247
2023-02-01 16:29:04 +00:00
Marco Trevisan
155e44652e Merge branch 'gstring-free-warning' into 'main'
Make g_string_free (_, FALSE) warn on unused result

See merge request GNOME/glib!3226
2023-02-01 16:28:02 +00:00
Marco Trevisan
151ca8d28d Merge branch 'gdbus-test-leak' into 'main'
tests: Fix a few minor leaks in gdbus-example-peer

See merge request GNOME/glib!3246
2023-02-01 16:24:57 +00:00
Kukuh Syafaat
76639a3620 Update Indonesian translation 2023-02-01 02:44:58 +00:00
Philip Withnall
b3389b66d6 tests: Fix a minor leak in the cxx string append tests
See https://gitlab.gnome.org/GNOME/glib/-/jobs/2547640

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2904
2023-01-31 11:52:11 +00:00
Philip Withnall
bd5e57ef17 tests: Fix a few minor leaks in gdbus-example-peer
One leak spotted by the Coverity, the others found via valgrind.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Coverity CID: #1504322
2023-01-31 11:44:44 +00:00
Aleksandr Melman
f499e37979 Update Russian translation 2023-01-29 22:11:03 +00:00
Yuri Chornoivan
eafd19da29 Update Ukrainian translation 2023-01-27 20:47:17 +00:00
Marco Trevisan
183c646fea Merge branch 'gmain-cleanups' into 'main'
GMainContext: Use nullable context in docs (and in some missing code)

See merge request GNOME/glib!3234
2023-01-27 14:03:13 +00:00
Philip Withnall
0bf7e8a1f4 Merge branch 'issue-2898-g_print_encoding' into 'main'
Document g_print and g_printerr encoding behaviour

Closes #2898

See merge request GNOME/glib!3233
2023-01-27 14:01:59 +00:00
Daniel Carpenter
04879542a4 Document g_print and g_printerr encoding behaviour 2023-01-27 14:01:58 +00:00
Sergey Bugaev
c121118bc4 tests: Silence a warning
In case the OS does not support epoll and kqueue, we get the warning:

gio/tests/pollable.c: In function ‘test_pollable_unix_nulldev’:
gio/tests/pollable.c:266:7: warning: unused variable ‘fd’
[-Wunused-variable]
  266 |   int fd;

Get rid of it.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-01-27 11:58:56 +03:00
Sergey Bugaev
718f05d090 gwakeup: #include <stdint.h>
Since commit 94b658ab4c, gwakeup.c has
started using C99 integer types, but has not included <stdint.h>. This
broke building on GNU/Hurd. Fix this by adding the missing include.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-01-27 11:58:56 +03:00
Sergey Bugaev
c3d07a625a string: Make g_string_free (_, FALSE) warn on unused result
...much like g_string_free_and_steal () does; by redirecting
g_string_free (_, FALSE) calls (when we can detect them) to
g_string_free_and_steal ().

This relies on some unpretty macros, but should be entirely transparent
to any users of g_string_free (). In particular, the macro only
evaluates its arguments once, no matter which branch ends up being
taken. The ternary operator the macro expands to always gets optimized
out, even at -O0: there is only one call to either g_string_free () or
g_string_free_and_steal () in the compiled code, with no run-time
branching.

Add a test for ensuring this works as expected in C++ too.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-01-27 11:58:52 +03:00
Sergey Bugaev
bccff754b6 Use g_string_free_and_steal () more
Now that there is g_string_free_and_steal (), we can use it instead of
the older g_string_free (_, FALSE). Make sure to use its return value
while doing so, as opposed to manually accessing string->str, to avoid
compiler warnings and make the intent more explicit.

This is all done in preparation for making g_string_free (_, FALSE) warn
on unused return value much like g_string_free_and_steal (), which will
happen in the next commit.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-01-27 11:55:27 +03:00
Marco Trevisan
5e40004bdb Merge branch 'gstrdup-inline' into 'main'
gstrfuncs: Add inline version of g_strdup()

See merge request GNOME/glib!3209
2023-01-26 18:38:37 +00:00
Marco Trevisan (Treviño)
7ac6c3dc9b gmain: Avoid checking for context value in internal function
This is something that is supposed to do by the public API, as everywhere
else the internal functions should be called with proper parameters instead
2023-01-26 18:04:13 +01:00
Marco Trevisan (Treviño)
39557fc4ae gmain: Explicitly mark @context as not nullable in ref/unref operations
It's quite clear already, but let's mark it even more explicit.
2023-01-26 18:04:13 +01:00
Marco Trevisan (Treviño)
1f8787116a gmain: Support nullable GMainContext in all the functions
All the GMainContext functions are supposed to work with a NULL context to
use the default one, but some were not doing it.

So adjust them.
2023-01-26 18:04:13 +01:00
Marco Trevisan
2cbc90cc1e Merge branch '2901-gio-executable-docs' into 'main'
gappinfo: Document that g_app_info_get_executable() should not be spawned

Closes #2901

See merge request GNOME/glib!3240
2023-01-26 16:41:16 +00:00
Marco Trevisan (Treviño)
3b2c7aba99 gmain: Mark context as nullable in docs where appropriate
GMainContext can be NULL in various functions, but we don't mark it as such.
2023-01-26 17:28:30 +01:00
Marco Trevisan (Treviño)
62ee931fce gmain: Always use "global-default main context" terminology in docs
That's also what we do in the GLib tutorial [1], so let's be consistent here

[1] https://gitlab.gnome.org/Teams/documentation/developer-www/-/blob/main/source/tutorials/main-contexts.rst
2023-01-26 17:26:15 +01:00
Marco Trevisan (Treviño)
23da6bade0 {glib,gio}/cxx: Add more tests for C++ inline funcs
These could behave differently in C++ so let's ensure this is not the
case.
2023-01-26 16:52:36 +01:00
Marco Trevisan (Treviño)
cc0fb5e77c gstrfuncs: Add inline version of g_strdup()
g_strdup() is often used to duplicate static strings, in these cases the
compiler could use a faster path because it knows the length of the
string at compile time, but this cannot happen because our g_strdup()
implementation is hidden.

To improve this case, we add a simple implementation of g_strdup() when
it is used with static or NULL strings that explicitly uses strlen,
g_malloc and memcpy to give hints to the compiler how to behave better.

This has definitely some benefits in terms of performances, causing an
iteration of 1000000 string duplication to drop from 2.7002s to 1.9428s
for a static string and from ~0.6584s to ~0.4408 for a NULL one.

Since compiler can optimize these cases quite a bit, the generated code
[2] is not increasing a lot, given that it can now avoid generating some
code or do it in few simpler steps.

Update tests to cover both inlined and non inlined cases.

[1] https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3209#note_1644383
[2] https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3209#note_1646662
2023-01-26 16:51:05 +01:00
Marco Trevisan (Treviño)
ed42f57704 tests/strfuncs: Add test for g_strdup() with empty string 2023-01-26 16:49:28 +01:00
Marco Trevisan (Treviño)
9cd90d97ae tests/strfuncs: Ensure that inlined functions really are macros
Add a compile check to ensure that the functions we have inlined are
actually macros when under gcc (and friends).
2023-01-26 16:49:28 +01:00
Marco Trevisan (Treviño)
a9ee3a5faa gstrfuncs: Ignore parsing inline macro versions for docs and g-i
We have actual definitions for these functions so we should ignore their
inline versions, not to potentially break doc parsers due to the different
argument names.

For some reasons we can't merge the check together with the gnu C check
if, otherwise the check gets ignored by doc parser.
2023-01-26 16:49:28 +01:00
Philip Withnall
a4fe981a7f Merge branch 'gstring-inline-null-handling' into 'main'
gstring: Gracefully handle NULL parameters in inline append

Closes #2890

See merge request GNOME/glib!3217
2023-01-26 15:46:03 +00:00
Marco Trevisan
452e9957a4 Merge branch 'leak-suppressions' into 'main'
Add a few suppressions to glib.supp and fix a minor bug in gapplication test

See merge request GNOME/glib!3223
2023-01-26 15:40:22 +00:00
Philip Withnall
ac30b7d824 Merge branch 'leak-fix' into 'main'
tests/desktop-app-info: fix stack-use-after-scope

See merge request GNOME/glib!3187
2023-01-26 15:36:22 +00:00
Philip Withnall
c53f9c0d37 gappinfo: Document that g_app_info_get_executable() should not be spawned
Spawning a process correctly is a lot more complicated than just bunging
an argument onto the return value from this function.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2901
2023-01-26 14:54:35 +00:00
Philip Withnall
287314c5a9 Merge branch 'regex-escape-string-bad-gir' into 'main'
g_regex_escape_string: bad GIR: utf8[] -> utf8

See merge request GNOME/glib!3236
2023-01-26 14:47:13 +00:00