Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
96c44901
Commit
96c44901
authored
Oct 25, 2010
by
Rafaël Carré
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ncurses: improve array cleanup
factorize
parent
f78010cf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
31 deletions
+23
-31
modules/gui/ncurses.c
modules/gui/ncurses.c
+23
-31
No files found.
modules/gui/ncurses.c
View file @
96c44901
...
@@ -194,23 +194,34 @@ struct intf_sys_t
...
@@ -194,23 +194,34 @@ struct intf_sys_t
* Directories
* Directories
*****************************************************************************/
*****************************************************************************/
static
int
comp_dir_entries
(
const
void
*
pp_dir_entry1
,
static
void
DirsDestroy
(
intf_sys_t
*
p_sys
)
const
void
*
pp_dir_entry2
)
{
while
(
p_sys
->
i_dir_entries
)
{
struct
dir_entry_t
*
p_dir_entry
;
p_dir_entry
=
p_sys
->
pp_dir_entries
[
--
p_sys
->
i_dir_entries
];
free
(
p_dir_entry
->
psz_path
);
free
(
p_dir_entry
);
}
free
(
p_sys
->
pp_dir_entries
);
p_sys
->
pp_dir_entries
=
NULL
;
}
static
int
comp_dir_entries
(
const
void
*
pp_dir_entry1
,
const
void
*
pp_dir_entry2
)
{
{
struct
dir_entry_t
*
p_dir_entry1
=
*
(
struct
dir_entry_t
**
)
pp_dir_entry1
;
struct
dir_entry_t
*
p_dir_entry1
=
*
(
struct
dir_entry_t
**
)
pp_dir_entry1
;
struct
dir_entry_t
*
p_dir_entry2
=
*
(
struct
dir_entry_t
**
)
pp_dir_entry2
;
struct
dir_entry_t
*
p_dir_entry2
=
*
(
struct
dir_entry_t
**
)
pp_dir_entry2
;
if
(
p_dir_entry1
->
b_file
==
p_dir_entry2
->
b_file
)
if
(
p_dir_entry1
->
b_file
==
p_dir_entry2
->
b_file
)
return
strcasecmp
(
p_dir_entry1
->
psz_path
,
p_dir_entry2
->
psz_path
);
return
strcasecmp
(
p_dir_entry1
->
psz_path
,
p_dir_entry2
->
psz_path
);
else
return
(
p_dir_entry1
->
b_file
?
1
:
-
1
)
;
return
p_dir_entry1
->
b_file
?
1
:
-
1
;
}
}
static
void
ReadDir
(
intf_thread_t
*
p_intf
)
static
void
ReadDir
(
intf_thread_t
*
p_intf
)
{
{
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
DIR
*
p_current_dir
;
DIR
*
p_current_dir
;
int
i
;
if
(
!
p_sys
->
psz_current_dir
||
!*
p_sys
->
psz_current_dir
)
if
(
!
p_sys
->
psz_current_dir
||
!*
p_sys
->
psz_current_dir
)
{
{
...
@@ -232,15 +243,7 @@ static void ReadDir(intf_thread_t *p_intf)
...
@@ -232,15 +243,7 @@ static void ReadDir(intf_thread_t *p_intf)
}
}
/* Clean the old shit */
/* Clean the old shit */
for
(
i
=
0
;
i
<
p_sys
->
i_dir_entries
;
i
++
)
DirsDestroy
(
p_sys
);
{
struct
dir_entry_t
*
p_dir_entry
=
p_sys
->
pp_dir_entries
[
i
];
free
(
p_dir_entry
->
psz_path
);
REMOVE_ELEM
(
p_sys
->
pp_dir_entries
,
p_sys
->
i_dir_entries
,
i
);
free
(
p_dir_entry
);
}
p_sys
->
pp_dir_entries
=
NULL
;
p_sys
->
i_dir_entries
=
0
;
/* while we still have entries in the directory */
/* while we still have entries in the directory */
while
((
psz_entry
=
vlc_readdir
(
p_current_dir
)))
while
((
psz_entry
=
vlc_readdir
(
p_current_dir
)))
...
@@ -310,17 +313,15 @@ static void ReadDir(intf_thread_t *p_intf)
...
@@ -310,17 +313,15 @@ static void ReadDir(intf_thread_t *p_intf)
* Playlist
* Playlist
*****************************************************************************/
*****************************************************************************/
static
void
PlaylistDestroy
(
intf_
thread_t
*
p_intf
)
static
void
PlaylistDestroy
(
intf_
sys_t
*
p_sys
)
{
{
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
while
(
p_sys
->
i_plist_entries
)
while
(
p_sys
->
i_plist_entries
)
{
{
struct
pl_item_t
*
p_pl_item
=
p_sys
->
pp_plist
[
0
];
struct
pl_item_t
*
p_pl_item
=
p_sys
->
pp_plist
[
--
p_sys
->
i_plist_entries
];
free
(
p_pl_item
->
psz_display
);
free
(
p_pl_item
->
psz_display
);
REMOVE_ELEM
(
p_sys
->
pp_plist
,
p_sys
->
i_plist_entries
,
0
);
free
(
p_pl_item
);
free
(
p_pl_item
);
}
}
free
(
p_sys
->
pp_plist
);
p_sys
->
pp_plist
=
NULL
;
p_sys
->
pp_plist
=
NULL
;
}
}
...
@@ -394,7 +395,7 @@ static void PlaylistRebuild(intf_thread_t *p_intf)
...
@@ -394,7 +395,7 @@ static void PlaylistRebuild(intf_thread_t *p_intf)
PL_LOCK
;
PL_LOCK
;
/* First clear the old one */
/* First clear the old one */
PlaylistDestroy
(
p_
intf
);
PlaylistDestroy
(
p_
sys
);
/* Build the new one */
/* Build the new one */
PlaylistAddNode
(
p_intf
,
PlaylistGetRoot
(
p_intf
),
0
,
""
);
PlaylistAddNode
(
p_intf
,
PlaylistGetRoot
(
p_intf
),
0
,
""
);
...
@@ -1702,7 +1703,6 @@ static int HandleKey(intf_thread_t *p_intf, int i_key)
...
@@ -1702,7 +1703,6 @@ static int HandleKey(intf_thread_t *p_intf, int i_key)
default:
default:
p_sys
->
i_current_view
=
VIEW_CATEGORY
;
p_sys
->
i_current_view
=
VIEW_CATEGORY
;
}
}
//p_sys->b_need_update = true;
PlaylistRebuild
(
p_intf
);
PlaylistRebuild
(
p_intf
);
goto
end
;
goto
end
;
...
@@ -2468,16 +2468,8 @@ static void Close(vlc_object_t *p_this)
...
@@ -2468,16 +2468,8 @@ static void Close(vlc_object_t *p_this)
intf_thread_t
*
p_intf
=
(
intf_thread_t
*
)
p_this
;
intf_thread_t
*
p_intf
=
(
intf_thread_t
*
)
p_this
;
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
PlaylistDestroy
(
p_intf
);
PlaylistDestroy
(
p_sys
);
DirsDestroy
(
p_sys
);
while
(
p_sys
->
i_dir_entries
)
{
struct
dir_entry_t
*
p_dir_entry
=
p_sys
->
pp_dir_entries
[
0
];
free
(
p_dir_entry
->
psz_path
);
REMOVE_ELEM
(
p_sys
->
pp_dir_entries
,
p_sys
->
i_dir_entries
,
0
);
free
(
p_dir_entry
);
}
p_sys
->
pp_dir_entries
=
NULL
;
free
(
p_sys
->
psz_current_dir
);
free
(
p_sys
->
psz_current_dir
);
free
(
p_sys
->
psz_search_chain
);
free
(
p_sys
->
psz_search_chain
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment