mirror of
https://github.com/mpv-player/mpv
synced 2024-12-25 16:33:02 +00:00
ta: add a helper macro
This commit is contained in:
parent
1a8af89b7d
commit
969c011522
4
ta/ta.h
4
ta/ta.h
@ -94,6 +94,9 @@ bool ta_vasprintf_append_buffer(char **str, const char *fmt, va_list ap) TA_PRF(
|
||||
|
||||
#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
|
||||
|
||||
#define ta_dup_ptrtype(ta_parent, ptr) \
|
||||
(TA_TYPEOF(ptr))ta_memdup(ta_parent, ptr, sizeof(*(ptr)))
|
||||
|
||||
// Ugly macros that crash on OOM.
|
||||
// All of these mirror real functions (with a 'x' added after the 'ta_'
|
||||
// prefix), and the only difference is that they will call abort() on allocation
|
||||
@ -121,6 +124,7 @@ bool ta_vasprintf_append_buffer(char **str, const char *fmt, va_list ap) TA_PRF(
|
||||
#define ta_xnew_array_size(...) ta_oom_p(ta_new_array_size(__VA_ARGS__))
|
||||
#define ta_xnew_ptrtype(...) ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
|
||||
#define ta_xnew_array_ptrtype(...) ta_oom_g(ta_new_array_ptrtype(__VA_ARGS__))
|
||||
#define ta_xdup_ptrtype(...) ta_oom_g(ta_dup_ptrtype(__VA_ARGS__))
|
||||
|
||||
#define ta_xsteal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_xsteal_(ta_parent, ptr)
|
||||
#define ta_xrealloc(ta_parent, ptr, type, count) \
|
||||
|
Loading…
Reference in New Issue
Block a user