associate a deallocation for opendir

This patch associates closedir as a deallocation for opendir and fdopendir.
This required moving the closedir declaration above the other 2 functions.

Reviewed-by: Paul Eggert <eggert@cs.ucla.edu>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
This commit is contained in:
Steve Grubb 2022-03-11 15:29:06 -05:00 committed by Siddhesh Poyarekar
parent 0c03669626
commit 0e12ca0241
1 changed files with 17 additions and 15 deletions

View File

@ -126,21 +126,6 @@ enum
The actual structure is opaque to users. */
typedef struct __dirstream DIR;
/* Open a directory stream on NAME.
Return a DIR stream on the directory, or NULL if it could not be opened.
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern DIR *opendir (const char *__name) __nonnull ((1));
#ifdef __USE_XOPEN2K8
/* Same as opendir, but open the stream on the file descriptor FD.
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern DIR *fdopendir (int __fd);
#endif
/* Close the directory stream DIRP.
Return 0 if successful, -1 if not.
@ -148,6 +133,23 @@ extern DIR *fdopendir (int __fd);
marked with __THROW. */
extern int closedir (DIR *__dirp) __nonnull ((1));
/* Open a directory stream on NAME.
Return a DIR stream on the directory, or NULL if it could not be opened.
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern DIR *opendir (const char *__name) __nonnull ((1))
__attribute_malloc__ __attr_dealloc (closedir, 1);
#ifdef __USE_XOPEN2K8
/* Same as opendir, but open the stream on the file descriptor FD.
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern DIR *fdopendir (int __fd)
__attribute_malloc__ __attr_dealloc (closedir, 1);
#endif
/* Read a directory entry from DIRP. Return a pointer to a `struct
dirent' describing the entry, or NULL for EOF or error. The
storage returned may be overwritten by a later readdir call on the