Commit Graph

15 Commits

Author SHA1 Message Date
Alexandre Janniaux d1bb14557c vlc_cxx_helpers.hpp: enable file with -DDOC 2023-08-03 08:56:58 +00:00
Alexandre Janniaux 2e577b4d45 vlc_cxx_helpers.hpp: fix documentation parameter name 2023-08-03 08:56:58 +00:00
Romain Vimont 98d7763c81 vlc_shared_data_ptr: accept implicit ctor for null
The main constructor, accepting a pointer, is explicit:

    my_ptr_type *p = ...;
    MySharedPtr ptr = p;   /* invalid */
    MySharedPtr ptr{ p };  /* ok */

This prevents to mistakenly assign a pointer to a shared pointer.

However, assignment to nullptr should be acceptable:

    MySharedPtr ptr = nullptr;  /* should be ok */
2022-10-01 04:29:53 +00:00
Hugo Beauzée-Luyssen 79b0d4b284 cxx_helpers: url: Fix leak on move assignment 2021-05-19 20:22:32 +00:00
Hugo Beauzée-Luyssen 41bea79465 cxx_helpers: url: Fix leak on error 2021-05-19 20:22:32 +00:00
Hugo Beauzée-Luyssen 43687100ea cxx_helpers: url: Mark constructors as explicit 2021-05-19 20:22:32 +00:00
Hugo Beauzée-Luyssen 1b64ac0e2e cxx helpers: Add an url helper 2020-06-22 12:48:51 +02:00
Rémi Denis-Courmont a18c4d6570 thread: remove vlc_cond_destroy() 2020-02-21 19:17:53 +02:00
Rémi Denis-Courmont a3226cf890 thread: remove vlc_mutex_destroy() 2020-02-21 19:16:09 +02:00
Rémi Denis-Courmont 6d324addef thread: remove vlc_sem_destroy()
This has become a useless no-op on all platforms.
2020-02-17 18:44:05 +02:00
Hugo Beauzée-Luyssen 741eca07fc cxx helpers: shared_data: Add nullptr comparison operators
Signed-off-by: Thomas Guillem <thomas@gllm.fr>
2019-04-10 08:53:18 +02:00
Romain Vimont bd319b9172 vlc_shared_data_ptr: make operator bool() explicit
Like unique_ptr, make the operator bool() explicit, so that it is only
called implicitly when the value may be "contextually converted to bool"
(if, while, etc.).

Suggested-by: Filip Roséen <filip@atch.se>
Signed-off-by: Thomas Guillem <thomas@gllm.fr>
2018-11-23 16:45:23 +01:00
Romain Vimont 40c6d71fd9 include: add C++ wrapper for C shared resources
Add a helper to create RAII wrappers for C shared resources, which
automatically call the Hold() and Release() functions associated to the
raw pointer.

Just declare a new shared resource wrapper type:

    using InputItemPtr = vlc_shared_data_ptr_type(input_item_t,
                                                  input_item_Hold,
                                                  input_item_Release);

Then use this new type directly:

    input_item_t *ptr = /* ... */;
    InputItemPtr item(ptr);
    QString name = item->psz_name;
    InputItemPtr other = item; /* hold automatically */
2018-11-15 14:34:04 +01:00
Hugo Beauzée-Luyssen 131275d3c6 Add C++ wrappers for mutex/cond/sem 2018-08-21 13:28:27 +02:00
Hugo Beauzée-Luyssen 0c4fc55326 include: Add C++ memory management helpers 2018-07-17 22:35:29 +02:00