Skip to content
  • Romain Vimont's avatar
    include: add C++ wrapper for C shared resources · 40c6d71f
    Romain Vimont authored and Thomas Guillem's avatar Thomas Guillem committed
    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 */
    40c6d71f