1
mirror of https://github.com/mpv-player/mpv synced 2024-11-03 03:19:24 +01:00
mpv/ta
wm4 d230194f62 ta: remove TA_FREEP NULL check
The NULL check triggers a gcc warning when passing the address of a
variable to it. I was about to silence the warning with some equivalent
code (that just happens to shut up gcc), but then I decided to remove
the NULL check as I don't see a reason why we should allow this. We
don't use it in the existing code anyway (all callers do something like
TA_FREEP(&structptr->member), which is always non-NULL).

Also fix some of the macro argument "quoting".
2017-01-08 07:32:44 +01:00
..
README ta/README: fix typos 2014-10-13 18:56:42 +02:00
ta_talloc.c Replace talloc 2013-10-13 01:36:09 +02:00
ta_talloc.h ta: remove TA_FREEP NULL check 2017-01-08 07:32:44 +01:00
ta_utils.c Initial Android support 2016-02-10 21:29:36 +01:00
ta.c ta: clarify a corner case 2014-02-23 16:50:51 +01:00
ta.h build: fix compilation with mingw-w64/Clang 2016-11-17 23:34:20 +11:00

TA ("Tree Allocator") is a wrapper around malloc() and related functions,
adding features like automatically freeing sub-trees of memory allocations if
a parent allocation is freed.

Generally, the idea is that every TA allocation can have a parent (indicated
by the ta_parent argument in allocation function calls). If a parent is freed,
its child allocations are automatically freed as well. It is also allowed to
free a child before the parent, or to move a child to another parent with
ta_set_parent().

It also provides a bunch of convenience macros and debugging facilities.

The TA functions are documented in the implementation files (ta.c, ta_utils.c).

TA is intended to be useable as library independent from mpv. It doesn't
depend on anything mpv specific.

Note:
-----

mpv doesn't use the TA API yet for two reasons: first, the TA API is not
necessarily finalized yet. Second, it should be easily possible to revert
the commit adding TA, and changing all the code would not allow this.

Especially the naming schema for some TA functions is still somewhat
undecided. (The talloc naming is a bit verbose at times.)

For now, mpv goes through a talloc wrapper, which maps the talloc API to TA.
New code should still use talloc as well. At one point, all talloc calls
will be replaced with TA calls, and the talloc wrapper will be removed.

Documentation for the talloc API is here:

    http://talloc.samba.org/talloc/doc/html/modules.html

There are some minor differences with mpv's talloc bridge. mpv calls abort()
on allocation failures, and the talloc_set_destructor() signature is slightly
different. libtalloc also has a weird 256MB limit per allocation. The talloc
wrapper supports only a strict subset of libtalloc functionality used by mpv.