Skip to content

Commit

Permalink
allocator: add missing virtual destructor (#3)
Browse files Browse the repository at this point in the history
add missing virtual destructor to base class and free gbm device on
destruction of CGBMAllocator
  • Loading branch information
gulafaran authored Jul 6, 2024
1 parent 29c415a commit 263cb16
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/aquamarine/allocator/Allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace Aquamarine {

class IAllocator {
public:
virtual ~IAllocator() = default;
virtual Hyprutils::Memory::CSharedPointer<IBuffer> acquire(const SAllocatorBufferParams& params, Hyprutils::Memory::CSharedPointer<CSwapchain> swapchain) = 0;
virtual Hyprutils::Memory::CSharedPointer<CBackend> getBackend() = 0;
};
Expand Down
1 change: 1 addition & 0 deletions include/aquamarine/allocator/GBM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace Aquamarine {

class CGBMAllocator : public IAllocator {
public:
~CGBMAllocator();
static Hyprutils::Memory::CSharedPointer<CGBMAllocator> create(int drmfd_, Hyprutils::Memory::CWeakPointer<CBackend> backend_);

virtual Hyprutils::Memory::CSharedPointer<IBuffer> acquire(const SAllocatorBufferParams& params, Hyprutils::Memory::CSharedPointer<CSwapchain> swapchain_);
Expand Down
5 changes: 5 additions & 0 deletions src/allocator/GBM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ SDMABUFAttrs Aquamarine::CGBMBuffer::dmabuf() {
return attrs;
}

CGBMAllocator::~CGBMAllocator() {
if (gbmDevice)
gbm_device_destroy(gbmDevice);
}

SP<CGBMAllocator> Aquamarine::CGBMAllocator::create(int drmfd_, Hyprutils::Memory::CWeakPointer<CBackend> backend_) {
uint64_t capabilities = 0;
if (drmGetCap(drmfd_, DRM_CAP_PRIME, &capabilities) || !(capabilities & DRM_PRIME_CAP_EXPORT)) {
Expand Down

0 comments on commit 263cb16

Please sign in to comment.