From 28f2d7454d5ea997dec691376ebcdf4c4e0454b4 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 12 Apr 2020 12:24:19 +0200 Subject: [PATCH] ta: minor simplification for talloc_steal Since commit f6615f00eeb0, it can't fail anymore. --- ta/ta.h | 2 -- ta/ta_talloc.h | 2 +- ta/ta_utils.c | 8 -------- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/ta/ta.h b/ta/ta.h index cc98cb7c5e..2af4747533 100644 --- a/ta/ta.h +++ b/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_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) \ (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. char *ta_xstrdup(void *ta_parent, const char *str); 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_xrealloc_size(void *ta_parent, void *ptr, size_t size); diff --git a/ta/ta_talloc.h b/ta/ta_talloc.h index 0f5c3bccb5..cacc72ebe4 100644 --- a/ta/ta_talloc.h +++ b/ta/ta_talloc.h @@ -34,7 +34,7 @@ #define talloc_ptrtype ta_xnew_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_new ta_xnew_context #define talloc_set_destructor ta_set_destructor diff --git a/ta/ta_utils.c b/ta/ta_utils.c index 8d729a9028..62469686db 100644 --- a/ta/ta_utils.c +++ b/ta/ta_utils.c @@ -53,8 +53,6 @@ void *ta_new_context(void *ta_parent) /* Set parent of ptr to ta_parent, return the 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) { @@ -288,12 +286,6 @@ char *ta_oom_s(char *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 *new = ta_memdup(ta_parent, ptr, size);