[Patch] associate a deallocator for iconv_open
Steve Grubb
sgrubb@redhat.com
Fri Mar 11 22:04:46 GMT 2022
This patch associates iconv_close as a deallocator for iconv_open. This
required moving the iconv_close declaration above iconv_open.
---
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