[vlc-devel] [PATCH] core: object: clear res from vlc_object_delete()
Steve Lhomme
robux4 at ycbcr.xyz
Mon Jan 27 14:35:58 CET 2020
On 2020-01-27 14:18, Thomas Guillem wrote:
> Instead of clearing them from all kind of modules API.
I like this idea. (comments below)
> This will allow to use vlc_obj_*alloc() from all modules without wondering if
> resources will be cleaned. Indeed, some modules have their own close callbacks
> that don't need module_unneed() (that was calling vlc_objres_clear()) to be
> called to release them.
>
> Furthermore, vlc_objres_clear() is an internal API, so submodules using an API
> defined in modules and a close callback could not benefit from it.
> ---
> src/input/decoder_helpers.c | 1 -
> src/misc/objects.c | 1 +
> src/modules/modules.c | 2 --
> src/network/tls.c | 2 --
> src/video_output/display.c | 2 --
> src/video_output/opengl.c | 1 -
> src/video_output/window.c | 1 -
> 7 files changed, 1 insertion(+), 9 deletions(-)
>
> diff --git a/src/input/decoder_helpers.c b/src/input/decoder_helpers.c
> index e59cdcb3a10..ae022796336 100644
> --- a/src/input/decoder_helpers.c
> +++ b/src/input/decoder_helpers.c
> @@ -222,7 +222,6 @@ vlc_decoder_device_Release(vlc_decoder_device *device)
> {
> if (device->ops->close != NULL)
> device->ops->close(device);
> - vlc_objres_clear(VLC_OBJECT(device));
You're missing one just before a vlc_object_delete() at line 198.
> vlc_object_delete(device);
> }
> }
> diff --git a/src/misc/objects.c b/src/misc/objects.c
> index f87edd9827f..370f7a92e98 100644
> --- a/src/misc/objects.c
> +++ b/src/misc/objects.c
> @@ -135,6 +135,7 @@ void vlc_object_deinit(vlc_object_t *obj)
>
> void (vlc_object_delete)(vlc_object_t *obj)
> {
> + vlc_objres_clear(obj);
> vlc_object_deinit(obj);
> free(obj);
> }
> diff --git a/src/modules/modules.c b/src/modules/modules.c
> index 2df5702f840..93ca5c8fa75 100644
> --- a/src/modules/modules.c
> +++ b/src/modules/modules.c
> @@ -272,8 +272,6 @@ void module_unneed(vlc_object_t *obj, module_t *module)
>
> if (module->deactivate != NULL)
> module->deactivate(obj);
> -
> - vlc_objres_clear(obj);
Why not keep this one ? It may be deleted much later.
> }
>
> module_t *module_find (const char *name)
More information about the vlc-devel
mailing list