<html><head></head><body>Hi,<br><br>If you are going to change how plain strings are returned, I think first should be revisited whether the string should be a copy at all.<br><br>It looks to me that, in most case, we should just return a 'const char *' whose lifetime is the same as the input object, or until the object is modified. Thus we eliminate error cases *and* heap problems.<br><br>And the marquee getter can probably be removed completely. It's rather schizophrenic to query what is the marquee text that you just set. Probably never used in real life.<br><br><div class="gmail_quote">Le 24 mai 2019 12:47:31 GMT+03:00, Steve Lhomme <robux4@ycbcr.xyz> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail"><hr> include/vlc/libvlc.h | 8 ++++++++<br> include/vlc/libvlc_media.h | 2 ++<br> include/vlc/libvlc_media_player.h | 7 +++++--<br> lib/core.c | 5 +++++<br> lib/libvlc.sym | 1 +<br> 5 files changed, 21 insertions(+), 2 deletions(-)<br><br>diff --git a/include/vlc/libvlc.h b/include/vlc/libvlc.h<br>index 0ec0045c96..789b881f55 100644<br>--- a/include/vlc/libvlc.h<br>+++ b/include/vlc/libvlc.h<br>@@ -277,6 +277,14 @@ LIBVLC_API const char * libvlc_get_compiler(void);<br> */<br> LIBVLC_API const char * libvlc_get_changeset(void);<br> <br>+/**<br>+ * Frees a string returned by a LibVLC function.<br>+ *<br>+ * \param ptr the string pointer<br>+ * \version LibVLC 4.0.0 and later<br>+ */<br>+LIBVLC_API void libvlc_free_string( char *ptr );<br>+<br> /** \defgroup libvlc_event LibVLC asynchronous events<br> * LibVLC emits asynchronous events.<br> *<br>diff --git a/include/vlc/libvlc_media.h b/include/vlc/libvlc_media.h<br>index cd335a6e08..c72e026106 100644<br>--- a/include/vlc/libvlc_media.h<br>+++ b/include/vlc/libvlc_media.h<br>@@ -548,6 +548,7 @@ LIBVLC_API void libvlc_media_release( libvlc_media_t *p_md );<br> *<br> * \param p_md a media descriptor object<br> * \return string with mrl of media descriptor object<br>+ * (it result must be released \ref with libvlc_free_string()).<br> */<br> LIBVLC_API char *libvlc_media_get_mrl( libvlc_media_t *p_md );<br> <br>@@ -572,6 +573,7 @@ LIBVLC_API libvlc_media_t *libvlc_media_duplicate( libvlc_media_t *p_md );<br> * \param p_md the media descriptor<br> * \param e_meta the meta to read<br> * \return the media's meta<br>+ * (it result must be released \ref with libvlc_free_string()).<br> */<br> LIBVLC_API char *libvlc_media_get_meta( libvlc_media_t *p_md,<br> libvlc_meta_t e_meta );<br>diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h<br>index f4981cecbc..5f46cb3048 100644<br>--- a/include/vlc/libvlc_media_player.h<br>+++ b/include/vlc/libvlc_media_player.h<br>@@ -1491,7 +1491,7 @@ LIBVLC_API void libvlc_video_set_scale( libvlc_media_player_t *p_mi, float f_fac<br> *<br> * \param p_mi the media player<br> * \return the video aspect ratio or NULL if unspecified<br>- * (the result must be released with free()).<br>+ * (it result must be released \ref with libvlc_free_string()).<br> */<br> LIBVLC_API char *libvlc_video_get_aspect_ratio( libvlc_media_player_t *p_mi );<br> <br>@@ -1661,6 +1661,7 @@ void libvlc_chapter_descriptions_release( libvlc_chapter_description_t **p_chapt<br> *<br> * \param p_mi the media player<br> * \return the crop filter geometry or NULL if unset<br>+ * (it result must be released \ref with libvlc_free_string()).<br> */<br> LIBVLC_API char *libvlc_video_get_crop_geometry( libvlc_media_player_t *p_mi );<br> <br>@@ -1776,6 +1777,8 @@ LIBVLC_API int libvlc_video_get_marquee_int( libvlc_media_player_t *p_mi,<br> *<br> * \param p_mi libvlc media player<br> * \param option marq option to get \see libvlc_video_marquee_option_t<br>+ * \return the string corresponding to the marquee option<br>+ * (it result must be released with libvlc_free_string()).<br> */<br> LIBVLC_API char *libvlc_video_get_marquee_string( libvlc_media_player_t *p_mi,<br> unsigned option );<br>@@ -2086,7 +2089,7 @@ LIBVLC_API void libvlc_audio_output_device_set( libvlc_media_player_t *mp,<br> * \param mp media player<br> * \return the current audio output device identifier<br> * NULL if no device is selected or in case of error<br>- * (the result must be released with free()).<br>+ * (the result must be released \ref with libvlc_free_string()).<br> * \version LibVLC 3.0.0 or later.<br> */<br> LIBVLC_API char *libvlc_audio_output_device_get( libvlc_media_player_t *mp );<br>diff --git a/lib/core.c b/lib/core.c<br>index 6edf14b154..f5af61e459 100644<br>--- a/lib/core.c<br>+++ b/lib/core.c<br>@@ -151,6 +151,11 @@ const char * libvlc_get_changeset(void)<br> return psz_vlc_changeset;<br> }<br> <br>+void libvlc_free_string( void *ptr )<br>+{<br>+ free( ptr );<br>+}<br>+<br> static libvlc_module_description_t *module_description_list_get(<br> libvlc_instance_t *p_instance, const char *capability )<br> {<br>diff --git a/lib/libvlc.sym b/lib/libvlc.sym<br>index 436681a4c3..15c777b00a 100644<br>--- a/lib/libvlc.sym<br>+++ b/lib/libvlc.sym<br>@@ -49,6 +49,7 @@ libvlc_dialog_set_callbacks<br> libvlc_dialog_set_context<br> libvlc_event_attach<br> libvlc_event_detach<br>+libvlc_free_string<br> libvlc_get_changeset<br> libvlc_get_compiler<br> libvlc_get_fullscreen</pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>