Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
56a09450
Commit
56a09450
authored
Mar 18, 2008
by
Pierre d'Herbemont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vlc_objects.h: Export and implement vlc_object_set_destructor().
parent
879e3eb2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
2 deletions
+43
-2
include/vlc_objects.h
include/vlc_objects.h
+10
-0
src/libvlc.h
src/libvlc.h
+3
-2
src/misc/objects.c
src/misc/objects.c
+30
-0
No files found.
include/vlc_objects.h
View file @
56a09450
...
...
@@ -83,6 +83,12 @@
#define OBJECT_FLAGS_QUIET 0x0002
#define OBJECT_FLAGS_NOINTERACT 0x0004
/* Types */
typedef
void
(
*
vlc_destructor_t
)(
struct
vlc_object_t
*
);
/* Constants */
VLC_PUBLIC_API
const
vlc_destructor_t
kVLCDestructor
;
/*****************************************************************************
* The vlc_object_t type. Yes, it's that simple :-)
*****************************************************************************/
...
...
@@ -96,6 +102,7 @@ struct vlc_object_t
* Prototypes
*****************************************************************************/
VLC_EXPORT
(
void
*
,
__vlc_object_create
,
(
vlc_object_t
*
,
int
)
);
VLC_EXPORT
(
void
,
__vlc_object_set_destructor
,
(
vlc_object_t
*
,
vlc_destructor_t
)
);
VLC_EXPORT
(
void
,
__vlc_object_attach
,
(
vlc_object_t
*
,
vlc_object_t
*
)
);
VLC_EXPORT
(
void
,
__vlc_object_detach
,
(
vlc_object_t
*
)
);
VLC_EXPORT
(
void
*
,
vlc_object_get
,
(
int
)
);
...
...
@@ -111,6 +118,9 @@ VLC_EXPORT( void, vlc_list_release, ( vlc_list_t * ) );
#define vlc_object_create(a,b) \
__vlc_object_create( VLC_OBJECT(a), b )
#define vlc_object_set_destructor(a,b) \
__vlc_object_set_destructor( VLC_OBJECT(a), b )
#define vlc_object_detach(a) \
__vlc_object_detach( VLC_OBJECT(a) )
...
...
src/libvlc.h
View file @
56a09450
...
...
@@ -133,8 +133,9 @@ struct vlc_object_internals_t
vlc_spinlock_t
spin
;
/* Objects management */
unsigned
i_refcount
;
vlc_bool_t
b_attached
;
unsigned
i_refcount
;
vlc_destructor_t
pf_destructor
;
vlc_bool_t
b_attached
;
};
#define ZOOM_SECTION N_("Zoom")
...
...
src/misc/objects.c
View file @
56a09450
...
...
@@ -72,6 +72,12 @@
#endif
#include <assert.h>
/*****************************************************************************
* Constants
*****************************************************************************/
const
vlc_destructor_t
kVLCDestructor
=
NULL
;
/*****************************************************************************
* Local prototypes
*****************************************************************************/
...
...
@@ -193,6 +199,7 @@ vlc_object_t *vlc_custom_create( vlc_object_t *p_this, size_t i_size,
}
p_priv
->
i_refcount
=
1
;
p_priv
->
pf_destructor
=
kVLCDestructor
;
p_new
->
p_parent
=
NULL
;
p_new
->
pp_children
=
NULL
;
p_new
->
i_children
=
0
;
...
...
@@ -352,6 +359,24 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type )
}
/**
****************************************************************************
* Set the destructor of a vlc object
*
* This function sets the destructor of the vlc object. It will be called
* when the object is destroyed when the its refcount reaches 0.
* (It is called by the internal function vlc_object_destroy())
*****************************************************************************/
void
__vlc_object_set_destructor
(
vlc_object_t
*
p_this
,
vlc_destructor_t
pf_destructor
)
{
vlc_object_internals_t
*
p_priv
=
vlc_internals
(
p_this
);
vlc_mutex_lock
(
&
structure_lock
);
p_priv
->
pf_destructor
=
pf_destructor
;
vlc_mutex_unlock
(
&
structure_lock
);
}
/**
****************************************************************************
* Destroy a vlc object (Internal)
...
...
@@ -400,6 +425,11 @@ static void vlc_object_destroy( vlc_object_t *p_this )
abort
();
}
/* Call the custom "subclass" destructor */
if
(
p_priv
->
pf_destructor
)
p_priv
->
pf_destructor
(
p_this
);
/* Destroy the associated variables, starting from the end so that
* no memmove calls have to be done. */
while
(
p_priv
->
i_vars
)
...
...
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