Commit Graph

16 Commits

Author SHA1 Message Date
Philip Withnall
00bfb3ab44 tree: Fix various typos and outdated terminology
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>
2020-06-12 15:01:08 +01:00
Xavier Claessens
e5c2327dcb doc: Remove trailing dot that confuse gtkdoc 2019-07-10 10:10:58 -04:00
Daniel Boles
c9b255f6c6 garcbox.c: Fix typo atomit => atomic 2019-06-04 20:08:46 +01:00
Corentin Noël
5350f1271e docs: Use the right g_autoptr function when using an auxiliary function 2019-03-20 14:39:44 +00:00
Emmanuele Bassi
76d8fb65b2 Document the alignment for refcounted allocations
We use the same definition as malloc().
2018-12-18 11:18:43 +00:00
Emmanuele Bassi
87f0a5a219 Align the reference counted allocations
We need stronger alignment guarantees for the memory allocations done
through g_rc_box_alloc_full(): while the passed block size may be
aligned, we're not aligning the private data size; this means the
overall allocation may become unaligned, and this could raise issues
when we use the private data size as an offset to access the reference
count.

Fixes: #1581
2018-12-18 11:18:43 +00:00
Emmanuele Bassi
822b511cb6 Update rcbox annotations for acquire/release functions
The accepted behaviour for reference counting functions can be described
as such:

 - acquire: takes a pointer to a memory area and returns the same
   pointer with its reference count increased; this means that the
   returned value's ownership is fully transfered from the callee
   to the caller
 - release: takes a pointer to a memory area and drops the reference
   count; this means that the caller transfers the ownership of the
   argument to the callee

These annotations are mostly meant for documentation purposes: high
level language bindings are unlikely to use them, as they have their own
reference counting semantics on top of GLib's own, and they should not
expose this API to their own consumers.
2018-07-09 10:11:42 +01:00
Emmanuele Bassi
c342105e76 Add systemtap probes to refcounted data
Probes allow us to debug refcounting bugs.
2018-07-09 10:11:42 +01:00
Emmanuele Bassi
61ca2e4c85 Check for overflow when allocating RcBox
Since we're over-allocating the passed block size, we need to check that
we're not overflowing gsize when computing the actual allocation size.
2018-07-09 10:11:42 +01:00
Emmanuele Bassi
7c4ac58938 Allow NULL clear function when releasing references
Both g_rc_box_release_full() and g_atomic_rc_box_release_full() should
allow passing NULL as the clear function, to conform to the existing
coding practices in GLib.

Additionally, this allows us to reimplement release() in terms of
release_full(), and improve test coverage.
2018-07-09 10:11:42 +01:00
Emmanuele Bassi
68304ae583 Improve docs for g_rc_box/g_atomic_rc_box
Especially the preconditions and the annotations for the returned
values.
2018-07-09 10:11:42 +01:00
Emmanuele Bassi
3bc0499eb2 Rename g_arc_box to g_atomic_rc_box
Makes the API more self-explanatory.
2018-07-09 10:11:42 +01:00
Emmanuele Bassi
43b7a8f158 Add size accessor to RcBox and ArcBox
It may be useful to know how big a reference counted allocation is
outside of internal checks.
2018-07-09 10:11:42 +01:00
Emmanuele Bassi
4b33b03dd3 Improve the RcBox and ArcBox documentation
Use better examples, split up into sections, and mention use with
g_autoptr().
2018-07-09 10:11:42 +01:00
Emmanuele Bassi
8990c3c4d3 Make g_rc_box_dup()/g_arc_box_dup() more generic
It's more useful to have a dup() function that copies any blob of memory
into a reference counted allocation, than to have a dup() that only
copies a reference counted allocation.
2018-07-09 10:11:42 +01:00
Emmanuele Bassi
b607927a43 Add atomically refcounted data
GArcBox is the atomic reference counting version of GRcBox. Unlike
GRcBox, the reference acquisition and release on GArcBox are guaranteed
to be atomic, and thus they can be performed from different threads.

This is similar to Rust's Arc<Box<T>> combination of traits.
2018-07-09 10:11:42 +01:00