mirror of https://github.com/mpv-player/mpv
ta: minor simplification for talloc_steal
Since commit f6615f00ee
, it can't fail anymore.
This commit is contained in:
parent
55f16bad76
commit
28f2d7454d
2
ta/ta.h
2
ta/ta.h
|
@ -125,14 +125,12 @@ bool ta_vasprintf_append_buffer(char **str, const char *fmt, va_list ap) TA_PRF(
|
||||||
#define ta_xnew_array_ptrtype(...) ta_oom_g(ta_new_array_ptrtype(__VA_ARGS__))
|
#define ta_xnew_array_ptrtype(...) ta_oom_g(ta_new_array_ptrtype(__VA_ARGS__))
|
||||||
#define ta_xdup(...) ta_oom_g(ta_dup(__VA_ARGS__))
|
#define ta_xdup(...) ta_oom_g(ta_dup(__VA_ARGS__))
|
||||||
|
|
||||||
#define ta_xsteal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_xsteal_(ta_parent, ptr)
|
|
||||||
#define ta_xrealloc(ta_parent, ptr, type, count) \
|
#define ta_xrealloc(ta_parent, ptr, type, count) \
|
||||||
(type *)ta_xrealloc_size(ta_parent, ptr, ta_calc_array_size(sizeof(type), count))
|
(type *)ta_xrealloc_size(ta_parent, ptr, ta_calc_array_size(sizeof(type), count))
|
||||||
|
|
||||||
// Can't be macros, because the OOM logic is slightly less trivial.
|
// Can't be macros, because the OOM logic is slightly less trivial.
|
||||||
char *ta_xstrdup(void *ta_parent, const char *str);
|
char *ta_xstrdup(void *ta_parent, const char *str);
|
||||||
char *ta_xstrndup(void *ta_parent, const char *str, size_t n);
|
char *ta_xstrndup(void *ta_parent, const char *str, size_t n);
|
||||||
void *ta_xsteal_(void *ta_parent, void *ptr);
|
|
||||||
void *ta_xmemdup(void *ta_parent, void *ptr, size_t size);
|
void *ta_xmemdup(void *ta_parent, void *ptr, size_t size);
|
||||||
void *ta_xrealloc_size(void *ta_parent, void *ptr, size_t size);
|
void *ta_xrealloc_size(void *ta_parent, void *ptr, size_t size);
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
#define talloc_ptrtype ta_xnew_ptrtype
|
#define talloc_ptrtype ta_xnew_ptrtype
|
||||||
#define talloc_array_ptrtype ta_xnew_array_ptrtype
|
#define talloc_array_ptrtype ta_xnew_array_ptrtype
|
||||||
|
|
||||||
#define talloc_steal ta_xsteal
|
#define talloc_steal ta_steal
|
||||||
#define talloc_realloc_size ta_xrealloc_size
|
#define talloc_realloc_size ta_xrealloc_size
|
||||||
#define talloc_new ta_xnew_context
|
#define talloc_new ta_xnew_context
|
||||||
#define talloc_set_destructor ta_set_destructor
|
#define talloc_set_destructor ta_set_destructor
|
||||||
|
|
|
@ -53,8 +53,6 @@ void *ta_new_context(void *ta_parent)
|
||||||
|
|
||||||
/* Set parent of ptr to ta_parent, return the ptr.
|
/* Set parent of ptr to ta_parent, return the ptr.
|
||||||
* Note that ta_parent==NULL will simply unset the current parent of ptr.
|
* Note that ta_parent==NULL will simply unset the current parent of ptr.
|
||||||
* If the operation fails (on OOM), return NULL. (That's pretty bad behavior,
|
|
||||||
* but the only way to signal failure.)
|
|
||||||
*/
|
*/
|
||||||
void *ta_steal_(void *ta_parent, void *ptr)
|
void *ta_steal_(void *ta_parent, void *ptr)
|
||||||
{
|
{
|
||||||
|
@ -288,12 +286,6 @@ char *ta_oom_s(char *s)
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *ta_xsteal_(void *ta_parent, void *ptr)
|
|
||||||
{
|
|
||||||
ta_set_parent(ptr, ta_parent);
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *ta_xmemdup(void *ta_parent, void *ptr, size_t size)
|
void *ta_xmemdup(void *ta_parent, void *ptr, size_t size)
|
||||||
{
|
{
|
||||||
void *new = ta_memdup(ta_parent, ptr, size);
|
void *new = ta_memdup(ta_parent, ptr, size);
|
||||||
|
|
Loading…
Reference in New Issue