[Patch] associate a deallocator for iconv_open

Siddhesh Poyarekar siddhesh@gotplt.org
Mon Mar 14 08:13:36 GMT 2022


On 12/03/2022 03:34, Steve Grubb via Libc-alpha wrote:
> This patch associates iconv_close as a deallocator for iconv_open. This
> required moving the iconv_close declaration above iconv_open.

LGTM.  I'll push once I finish testing.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>

> 
> ---
>   iconv.h |   15 ++++++++-------
>   1 file changed, 8 insertions(+), 7 deletions(-)
> ---
> diff -urp glibc-2.35.9000-111-g2bbc694df2.orig/iconv/iconv.h glibc-2.35.9000-111-g2bbc694df2/iconv/iconv.h
> --- glibc-2.35.9000-111-g2bbc694df2.orig/iconv/iconv.h	2022-02-28 10:47:38.000000000 -0500
> +++ glibc-2.35.9000-111-g2bbc694df2/iconv/iconv.h	2022-03-11 15:06:20.679084344 -0500
> @@ -29,12 +29,19 @@ __BEGIN_DECLS
>   typedef void *iconv_t;
>   
>   
> +/* Free resources allocated for descriptor CD for code conversion.
> +
> +   This function is a possible cancellation point and therefore not
> +   marked with __THROW.  */
> +extern int iconv_close (iconv_t __cd);
> +
>   /* Allocate descriptor for code conversion from codeset FROMCODE to
>      codeset TOCODE.
>   
>      This function is a possible cancellation point and therefore not
>      marked with __THROW.  */
> -extern iconv_t iconv_open (const char *__tocode, const char *__fromcode);
> +extern iconv_t iconv_open (const char *__tocode, const char *__fromcode)
> +	__attribute_malloc__ __attr_dealloc (iconv_close, 1);
>   
>   /* Convert at most *INBYTESLEFT bytes from *INBUF according to the
>      code conversion algorithm specified by CD and place up to
> @@ -44,12 +51,6 @@ extern size_t iconv (iconv_t __cd, char
>   		     char **__restrict __outbuf,
>   		     size_t *__restrict __outbytesleft);
>   
> -/* Free resources allocated for descriptor CD for code conversion.
> -
> -   This function is a possible cancellation point and therefore not
> -   marked with __THROW.  */
> -extern int iconv_close (iconv_t __cd);
> -
>   __END_DECLS
>   
>   #endif /* iconv.h */
> 
> 
> 



More information about the Libc-alpha mailing list