summaryrefslogtreecommitdiffstats
path: root/talloc.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-10-13 01:16:30 +0200
committerwm4 <wm4@nowhere>2013-10-13 01:16:30 +0200
commitc613d802bc5d87a7be031aaf97996d96bd8af909 (patch)
tree5f18f9ceaf51cb077861099def7dabe3422676f3 /talloc.c
parent8d5f800567d81665820d308b7f2d482c18c51e15 (diff)
downloadmpv-c613d802bc5d87a7be031aaf97996d96bd8af909.tar.bz2
mpv-c613d802bc5d87a7be031aaf97996d96bd8af909.tar.xz
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.)
Diffstat (limited to 'talloc.c')
-rw-r--r--talloc.c18
1 files changed, 5 insertions, 13 deletions
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)