vlc 2.2.0-rc2 please check that vlc_DIR.
Posted: 15 Feb 2015 10:31
/include/vlc_fs.h
***line 48
#if defined( _WIN32 )
typedef struct vlc_DIR
{
_WDIR *wdir; /* MUST be first, see <vlc_fs.h> */
char *entry; <------------ this is new in 2.2.0
union
{
DWORD drives;
bool insert_dot_dot;
} u;
} vlc_DIR;
/src/win32/filesystem.c
***line 171
char *vlc_readdir (DIR *dir)
{
vlc_DIR *p_dir = (vlc_DIR *)dir;
free(p_dir->entry); <---------- this is a little problem. and other part to use entry. Because p_dir is type cast from (DIR *), struct DIR size is less then struct vlc_DIR.
I think after call vlc_readdir(), it need to free return value. But this is not right way.
Please check about that.
#if !VLC_WINSTORE_APP
/* Drive letters mode */
if (p_dir->wdir == NULL)
{
DWORD drives = p_dir->u.drives;
if (drives == 0)
return NULL; /* end */
unsigned int i;
for (i = 0; !(drives & 1); i++)
drives >>= 1;
p_dir->u.drives &= ~(1UL << i);
assert (i < 26);
if (asprintf (&p_dir->entry, "%c:\\", 'A' + i) == -1)
p_dir->entry = NULL;
}
else
#endif
if (p_dir->u.insert_dot_dot)
{
/* Adds "..", gruik! */
p_dir->u.insert_dot_dot = false;
p_dir->entry = strdup ("..");
}
else
{
struct _wdirent *ent = _wreaddir (p_dir->wdir);
p_dir->entry = (ent != NULL) ? FromWide (ent->d_name) : NULL;
}
return p_dir->entry;
}
***line 48
#if defined( _WIN32 )
typedef struct vlc_DIR
{
_WDIR *wdir; /* MUST be first, see <vlc_fs.h> */
char *entry; <------------ this is new in 2.2.0
union
{
DWORD drives;
bool insert_dot_dot;
} u;
} vlc_DIR;
/src/win32/filesystem.c
***line 171
char *vlc_readdir (DIR *dir)
{
vlc_DIR *p_dir = (vlc_DIR *)dir;
free(p_dir->entry); <---------- this is a little problem. and other part to use entry. Because p_dir is type cast from (DIR *), struct DIR size is less then struct vlc_DIR.
I think after call vlc_readdir(), it need to free return value. But this is not right way.
Please check about that.
#if !VLC_WINSTORE_APP
/* Drive letters mode */
if (p_dir->wdir == NULL)
{
DWORD drives = p_dir->u.drives;
if (drives == 0)
return NULL; /* end */
unsigned int i;
for (i = 0; !(drives & 1); i++)
drives >>= 1;
p_dir->u.drives &= ~(1UL << i);
assert (i < 26);
if (asprintf (&p_dir->entry, "%c:\\", 'A' + i) == -1)
p_dir->entry = NULL;
}
else
#endif
if (p_dir->u.insert_dot_dot)
{
/* Adds "..", gruik! */
p_dir->u.insert_dot_dot = false;
p_dir->entry = strdup ("..");
}
else
{
struct _wdirent *ent = _wreaddir (p_dir->wdir);
p_dir->entry = (ent != NULL) ? FromWide (ent->d_name) : NULL;
}
return p_dir->entry;
}