From c613d802bc5d87a7be031aaf97996d96bd8af909 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 13 Oct 2013 01:16:30 +0200 Subject: talloc: change talloc destructor signature Change talloc destructor so that they can never signal failure, and don't return a status code. This makes our talloc copy even more incompatible to upstream talloc, but on the other hand this is preparation for getting rid of talloc entirely. (The talloc replacement in the next commit won't allow the talloc_free equivalent to fail, and the destructor return value would be useless. But I don't want to change any mpv code either; the idea is that the talloc replacement commit can be reverted for some time in order to test whether the talloc replacement introduced a regression.) --- talloc.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'talloc.c') diff --git a/talloc.c b/talloc.c index 9b73fc19f0..ec017d9c89 100644 --- a/talloc.c +++ b/talloc.c @@ -135,7 +135,7 @@ struct talloc_reference_handle { void *ptr; }; -typedef int (*talloc_destructor_t)(void *); +typedef void (*talloc_destructor_t)(void *); struct talloc_chunk { struct talloc_chunk *next, *prev; @@ -406,11 +406,8 @@ void *talloc_pool(const void *context, size_t size) /* setup a destructor to be called on free of a pointer - the destructor should return 0 on success, or -1 on failure. - if the destructor fails then the free is failed, and the memory can - be continued to be used */ -void _talloc_set_destructor(const void *ptr, int (*destructor)(void *)) +void _talloc_set_destructor(const void *ptr, void (*destructor)(void *)) { struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); tc->destructor = destructor; @@ -432,12 +429,11 @@ int talloc_increase_ref_count(const void *ptr) this is referenced by a function pointer and should not be inline */ -static int talloc_reference_destructor(void *ptr) +static void talloc_reference_destructor(void *ptr) { struct talloc_reference_handle *handle = ptr; struct talloc_chunk *ptr_tc = talloc_chunk_from_ptr(handle->ptr); _TLIST_REMOVE(ptr_tc->refs, handle); - return 0; } /* @@ -539,10 +535,7 @@ static inline int _talloc_free(void *ptr) return -1; } tc->destructor = (talloc_destructor_t)-1; - if (d(ptr) == -1) { - tc->destructor = d; - return -1; - } + d(ptr); tc->destructor = NULL; } @@ -1651,10 +1644,9 @@ void *talloc_realloc_fn(const void *context, void *ptr, size_t size) } -static int talloc_autofree_destructor(void *ptr) +static void talloc_autofree_destructor(void *ptr) { autofree_context = NULL; - return 0; } static void talloc_autofree(void) -- cgit v1.2.3