[vlc-commits] objects: move documentation to header file
Rémi Denis-Courmont
git at videolan.org
Wed Mar 6 21:57:45 CET 2019
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Mar 6 19:55:21 2019 +0200| [e529781d3a7252da5b3fbddba6e4249649985802] | committer: Rémi Denis-Courmont
objects: move documentation to header file
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e529781d3a7252da5b3fbddba6e4249649985802
---
include/vlc_objects.h | 28 +++++++++++++++++++++++-----
src/misc/objects.c | 23 +++--------------------
2 files changed, 26 insertions(+), 25 deletions(-)
diff --git a/include/vlc_objects.h b/include/vlc_objects.h
index b5ad73d907..843a321e71 100644
--- a/include/vlc_objects.h
+++ b/include/vlc_objects.h
@@ -83,13 +83,31 @@ struct libvlc_int_t
struct vlc_common_members obj;
};
-/*****************************************************************************
- * Prototypes
- *****************************************************************************/
+/**
+ * Allocates and initializes a vlc object.
+ *
+ * @param i_size object byte size
+ *
+ * @return the new object, or NULL on error.
+ */
VLC_API void *vlc_object_create( vlc_object_t *, size_t ) VLC_MALLOC VLC_USED;
VLC_API vlc_object_t *vlc_object_find_name( vlc_object_t *, const char * ) VLC_USED VLC_DEPRECATED;
-VLC_API void * vlc_object_hold( vlc_object_t * );
-VLC_API void vlc_object_release( vlc_object_t * );
+
+/**
+ * Adds a weak reference to an object.
+ *
+ * This atomically increments the reference count of an object.
+ */
+VLC_API void * vlc_object_hold(vlc_object_t *obj);
+
+/**
+ * Drops a reference to an object.
+ *
+ * This atomically decrements the reference count.
+ * If the count reaches zero, the object is destroyed.
+ */
+VLC_API void vlc_object_release(vlc_object_t *obj);
+
VLC_API size_t vlc_list_children(vlc_object_t *, vlc_object_t **, size_t) VLC_USED;
/**
diff --git a/src/misc/objects.c b/src/misc/objects.c
index a3da483307..1f92381c26 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -264,15 +264,7 @@ void *vlc_custom_create (vlc_object_t *parent, size_t length,
return obj;
}
-#undef vlc_object_create
-/**
- * Allocates and initializes a vlc object.
- *
- * @param i_size object byte size
- *
- * @return the new object, or NULL on error.
- */
-void *vlc_object_create( vlc_object_t *p_this, size_t i_size )
+void *(vlc_object_create)(vlc_object_t *p_this, size_t i_size)
{
return vlc_custom_create( p_this, i_size, "generic" );
}
@@ -358,11 +350,7 @@ vlc_object_t *vlc_object_find_name( vlc_object_t *p_this, const char *psz_name )
return NULL;
}
-#undef vlc_object_hold
-/**
- * Increment an object reference counter.
- */
-void * vlc_object_hold( vlc_object_t *p_this )
+void *(vlc_object_hold)(vlc_object_t *p_this)
{
vlc_object_internals_t *internals = vlc_internals( p_this );
unsigned refs = atomic_fetch_add_explicit(&internals->refs, 1,
@@ -373,12 +361,7 @@ void * vlc_object_hold( vlc_object_t *p_this )
return p_this;
}
-#undef vlc_object_release
-/**
- * Drops a reference to an object (decrements the reference count).
- * If the count reaches zero, the object is destroyed.
- */
-void vlc_object_release (vlc_object_t *obj)
+void (vlc_object_release)(vlc_object_t *obj)
{
vlc_object_internals_t *priv = vlc_internals(obj);
unsigned refs = atomic_load_explicit(&priv->refs, memory_order_relaxed);
More information about the vlc-commits
mailing list