]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
associate a deallocator for iconv_open
authorSteve Grubb <sgrubb@redhat.com>
Fri, 11 Mar 2022 22:04:46 +0000 (17:04 -0500)
committerSiddhesh Poyarekar <siddhesh@sourceware.org>
Mon, 14 Mar 2022 14:32:49 +0000 (20:02 +0530)
This patch associates iconv_close as a deallocator for iconv_open. This
required moving the iconv_close declaration above iconv_open.

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

index aa936a350fbfeb5faab0f2122a7995e2fbdb8e1a..544425d4dcdeb1b92c01ca9e7eb42c4912280169 100644 (file)
@@ -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 **__restrict __inbuf,
                     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 */