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
60bd120e
Commit
60bd120e
authored
Jun 01, 2007
by
Pierre d'Herbemont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libvlc event: Fix the various leaks and point indication on where locking should be done.
parent
78f85ea0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
14 deletions
+34
-14
include/vlc/libvlc.h
include/vlc/libvlc.h
+8
-0
src/control/core.c
src/control/core.c
+1
-9
src/control/event.c
src/control/event.c
+25
-5
No files found.
include/vlc/libvlc.h
View file @
60bd120e
...
@@ -813,6 +813,14 @@ VLC_PUBLIC_API void libvlc_event_add_callback( libvlc_instance_t *p_instance,
...
@@ -813,6 +813,14 @@ VLC_PUBLIC_API void libvlc_event_add_callback( libvlc_instance_t *p_instance,
void
*
user_data
,
void
*
user_data
,
libvlc_exception_t
*
p_e
);
libvlc_exception_t
*
p_e
);
/**
* Unregister all callbacks notification from an instance
* \param p_instance the libvlc instance
* \param p_e an initialized exception pointer
*/
VLC_PUBLIC_API
void
libvlc_event_remove_all_callbacks
(
libvlc_instance_t
*
p_instance
,
libvlc_exception_t
*
p_e
);
/**
/**
* Unregister a callback notification
* Unregister a callback notification
* \param p_instance the libvlc instance
* \param p_instance the libvlc instance
...
...
src/control/core.c
View file @
60bd120e
...
@@ -107,15 +107,7 @@ libvlc_instance_t * libvlc_new( int argc, char **argv,
...
@@ -107,15 +107,7 @@ libvlc_instance_t * libvlc_new( int argc, char **argv,
void
libvlc_destroy
(
libvlc_instance_t
*
p_instance
,
libvlc_exception_t
*
p_e
)
void
libvlc_destroy
(
libvlc_instance_t
*
p_instance
,
libvlc_exception_t
*
p_e
)
{
{
struct
libvlc_callback_entry_list_t
*
p_listitem
=
p_instance
->
p_callback_list
;
libvlc_event_remove_all_callbacks
(
p_instance
,
p_e
/* current implementation never triggers it */
);
while
(
p_listitem
)
{
struct
libvlc_callback_entry_list_t
*
p_nextlistitem
=
p_listitem
->
next
;
free
(
p_listitem
);
p_listitem
=
p_nextlistitem
;
}
libvlc_InternalCleanup
(
p_instance
->
p_libvlc_int
);
libvlc_InternalCleanup
(
p_instance
->
p_libvlc_int
);
libvlc_InternalDestroy
(
p_instance
->
p_libvlc_int
,
VLC_FALSE
);
libvlc_InternalDestroy
(
p_instance
->
p_libvlc_int
,
VLC_FALSE
);
}
}
...
...
src/control/event.c
View file @
60bd120e
...
@@ -33,7 +33,7 @@ static int handle_event( vlc_object_t *p_this, char const *psz_cmd,
...
@@ -33,7 +33,7 @@ static int handle_event( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t
oldval
,
vlc_value_t
newval
,
vlc_value_t
oldval
,
vlc_value_t
newval
,
void
*
p_data
)
void
*
p_data
)
{
{
struct
libvlc_callback_entry_t
*
entry
=
p_data
;
struct
libvlc_callback_entry_t
*
entry
=
p_data
;
/* FIXME: we need some locking here */
libvlc_event_t
event
;
libvlc_event_t
event
;
event
.
type
=
entry
->
i_event_type
;
event
.
type
=
entry
->
i_event_type
;
switch
(
event
.
type
)
switch
(
event
.
type
)
...
@@ -63,7 +63,8 @@ static inline void add_callback_entry( struct libvlc_callback_entry_t *entry,
...
@@ -63,7 +63,8 @@ static inline void add_callback_entry( struct libvlc_callback_entry_t *entry,
/* malloc/free strategy:
/* malloc/free strategy:
* - alloc-ded in add_callback_entry
* - alloc-ded in add_callback_entry
* - free-ed by libvlc_event_remove_callback
* - free-ed by libvlc_event_remove_callback
* - free-ed in libvlc_destroy when entry is destroyed
* - free-ed in libvlc_destroy threw libvlc_event_remove_callback
* when entry is destroyed
*/
*/
new_listitem
=
malloc
(
sizeof
(
struct
libvlc_callback_entry_list_t
)
);
new_listitem
=
malloc
(
sizeof
(
struct
libvlc_callback_entry_list_t
)
);
new_listitem
->
elmt
=
entry
;
new_listitem
->
elmt
=
entry
;
...
@@ -95,8 +96,9 @@ void libvlc_event_add_callback( libvlc_instance_t *p_instance,
...
@@ -95,8 +96,9 @@ void libvlc_event_add_callback( libvlc_instance_t *p_instance,
/* malloc/free strategy:
/* malloc/free strategy:
* - alloc-ded in libvlc_event_add_callback
* - alloc-ded in libvlc_event_add_callback
* - free-ed by libvlc_event_add_callback on error
* - free-ed by libvlc_event_add_callback on error
* - Not free-ed by libvlc_event_remove_callback (FIXME leaks)
* - free-ed by libvlc_event_remove_callback
* - Not free-ed in libvlc_destroy when entry is destroyed (FIXME leaks)
* - free-ed in libvlc_destroy threw libvlc_event_remove_callback
* when entry is destroyed
*/
*/
entry
=
malloc
(
sizeof
(
struct
libvlc_callback_entry_t
)
);
entry
=
malloc
(
sizeof
(
struct
libvlc_callback_entry_t
)
);
entry
->
f_callback
=
f_callback
;
entry
->
f_callback
=
f_callback
;
...
@@ -131,6 +133,23 @@ void libvlc_event_add_callback( libvlc_instance_t *p_instance,
...
@@ -131,6 +133,23 @@ void libvlc_event_add_callback( libvlc_instance_t *p_instance,
return
;
return
;
}
}
void
libvlc_event_remove_all_callbacks
(
libvlc_instance_t
*
p_instance
,
libvlc_exception_t
*
p_e
)
{
struct
libvlc_callback_entry_list_t
*
p_listitem
=
p_instance
->
p_callback_list
;
while
(
p_listitem
)
{
libvlc_event_remove_callback
(
p_instance
,
p_listitem
->
elmt
->
i_event_type
,
p_listitem
->
elmt
->
f_callback
,
p_listitem
->
elmt
->
p_user_data
,
p_e
);
/* libvlc_event_remove_callback will reset the p_callback_list */
p_listitem
=
p_instance
->
p_callback_list
;
}
}
void
libvlc_event_remove_callback
(
libvlc_instance_t
*
p_instance
,
void
libvlc_event_remove_callback
(
libvlc_instance_t
*
p_instance
,
libvlc_event_type_t
i_event_type
,
libvlc_event_type_t
i_event_type
,
libvlc_callback_t
f_callback
,
libvlc_callback_t
f_callback
,
...
@@ -151,8 +170,9 @@ void libvlc_event_remove_callback( libvlc_instance_t *p_instance,
...
@@ -151,8 +170,9 @@ void libvlc_event_remove_callback( libvlc_instance_t *p_instance,
p_listitem
->
prev
->
next
=
p_listitem
->
next
;
p_listitem
->
prev
->
next
=
p_listitem
->
next
;
else
else
p_instance
->
p_callback_list
=
p_listitem
->
next
;
p_instance
->
p_callback_list
=
p_listitem
->
next
;
p_listitem
->
next
->
prev
=
p_listitem
->
prev
;
p_listitem
->
next
->
prev
=
p_listitem
->
prev
;
free
(
p_listitem
->
elmt
);
/* FIXME: need some locking here */
free
(
p_listitem
);
free
(
p_listitem
);
break
;
break
;
}
}
...
...
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