Merge branch 'filename_max' into 'master'

Improve handling of FILENAME_MAX

See merge request GNOME/glib!2055
This commit is contained in:
Sebastian Dröge 2021-04-23 08:40:21 +00:00
commit 0b863a4ea9
3 changed files with 6 additions and 4 deletions

View File

@ -135,7 +135,7 @@ _topendir (const _TCHAR *szPath)
nd->dd_dir.d_ino = 0;
nd->dd_dir.d_reclen = 0;
nd->dd_dir.d_namlen = 0;
memset (nd->dd_dir.d_name, 0, FILENAME_MAX);
memset (nd->dd_dir.d_name, 0, sizeof (nd->dd_dir.d_name));
return nd;
}

View File

@ -22,7 +22,7 @@ struct dirent
long d_ino; /* Always zero. */
unsigned short d_reclen; /* Always zero. */
unsigned short d_namlen; /* Length of name in d_name. */
char d_name[FILENAME_MAX]; /* File name. */
char d_name[FILENAME_MAX+1]; /* File name plus nul delimiter. */
};
#ifdef _WIN64
@ -76,7 +76,7 @@ struct _wdirent
long d_ino; /* Always zero. */
unsigned short d_reclen; /* Always zero. */
unsigned short d_namlen; /* Length of name in d_name. */
wchar_t d_name[FILENAME_MAX]; /* File name. */
wchar_t d_name[FILENAME_MAX+1]; /* File name plus nul delimiter. */
};
/*

View File

@ -60,7 +60,9 @@ struct _GDir
DIR *dirp;
#endif
#ifdef G_OS_WIN32
gchar utf8_buf[FILENAME_MAX*4];
/* maximum encoding of FILENAME_MAX UTF-8 characters, plus a nul terminator
* (FILENAME_MAX is not guaranteed to include one) */
gchar utf8_buf[FILENAME_MAX*4 + 1];
#endif
};