diff --git a/demux/demux.c b/demux/demux.c index 4fb121e29e..ba632218ec 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -116,12 +116,11 @@ static void ds_free_packs(struct demux_stream *ds) ds->eof = 0; } -static int packet_destroy(void *ptr) +static void packet_destroy(void *ptr) { struct demux_packet *dp = ptr; talloc_free(dp->avpacket); free(dp->allocation); - return 0; } static struct demux_packet *create_packet(size_t len) @@ -193,10 +192,9 @@ void free_demux_packet(struct demux_packet *dp) talloc_free(dp); } -static int destroy_avpacket(void *pkt) +static void destroy_avpacket(void *pkt) { av_free_packet(pkt); - return 0; } struct demux_packet *demux_copy_packet(struct demux_packet *dp) diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index 1e071f20e2..9b8881fc8a 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -717,10 +717,9 @@ static void seek_reset(demuxer_t *demux) priv->num_packets = 0; } -static int destroy_avpacket(void *pkt) +static void destroy_avpacket(void *pkt) { av_free_packet(pkt); - return 0; } static int read_more_av_packets(demuxer_t *demux) diff --git a/mpvcore/m_config.c b/mpvcore/m_config.c index d01d0ed07c..d54940ba5f 100644 --- a/mpvcore/m_config.c +++ b/mpvcore/m_config.c @@ -180,13 +180,12 @@ static void add_options(struct m_config *config, struct m_config_option *parent, const struct m_option *defs); -static int config_destroy(void *p) +static void config_destroy(void *p) { struct m_config *config = p; m_config_restore_backups(config); for (struct m_config_option *copt = config->opts; copt; copt = copt->next) m_option_free(copt->opt, copt->data); - return 0; } struct m_config *m_config_new(void *talloc_parent, size_t size, 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) diff --git a/talloc.h b/talloc.h index 909ce80ecf..60dda32811 100644 --- a/talloc.h +++ b/talloc.h @@ -113,7 +113,7 @@ typedef void TALLOC_CTX; /* The following definitions come from talloc.c */ void *_talloc(const void *context, size_t size); void *talloc_pool(const void *context, size_t size); -void _talloc_set_destructor(const void *ptr, int (*destructor)(void *)); +void _talloc_set_destructor(const void *ptr, void (*destructor)(void *)); int talloc_increase_ref_count(const void *ptr); size_t talloc_reference_count(const void *ptr); void *_talloc_reference(const void *context, const void *ptr); diff --git a/video/mp_image.c b/video/mp_image.c index 4015f27d4a..3bc76b669e 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -62,11 +62,10 @@ struct m_refcount { }; // Only for checking API usage -static int m_refcount_destructor(void *ptr) +static void m_refcount_destructor(void *ptr) { struct m_refcount *ref = ptr; assert(ref->refcount == 0); - return 0; } // Starts out with refcount==1, caller can set .arg and .free and .ext_* @@ -165,11 +164,10 @@ void mp_image_setfmt(struct mp_image *mpi, unsigned int out_fmt) mp_image_set_size(mpi, mpi->w, mpi->h); } -static int mp_image_destructor(void *ptr) +static void mp_image_destructor(void *ptr) { mp_image_t *mpi = ptr; m_refcount_unref(mpi->refcount); - return 0; } static int mp_chroma_div_up(int size, int shift) diff --git a/video/mp_image_pool.c b/video/mp_image_pool.c index 733f2059b4..1ef08b5e2d 100644 --- a/video/mp_image_pool.c +++ b/video/mp_image_pool.c @@ -58,11 +58,10 @@ struct image_flags { bool pool_alive; // the mp_image_pool references this }; -static int image_pool_destructor(void *ptr) +static void image_pool_destructor(void *ptr) { struct mp_image_pool *pool = ptr; mp_image_pool_clear(pool); - return 0; } struct mp_image_pool *mp_image_pool_new(int max_count) diff --git a/video/sws_utils.c b/video/sws_utils.c index bc9c408b3e..c90efe020c 100644 --- a/video/sws_utils.c +++ b/video/sws_utils.c @@ -150,13 +150,12 @@ static bool cache_valid(struct mp_sws_context *ctx) ctx->saturation == old->saturation; } -static int free_mp_sws(void *p) +static void free_mp_sws(void *p) { struct mp_sws_context *ctx = p; sws_freeContext(ctx->sws); sws_freeFilter(ctx->src_filter); sws_freeFilter(ctx->dst_filter); - return 0; } // You're supposed to set your scaling parameters on the returned context.