diff --git a/autotests/drm/mock_drm.cpp b/autotests/drm/mock_drm.cpp index a86e367417..9b65720af9 100644 --- a/autotests/drm/mock_drm.cpp +++ b/autotests/drm/mock_drm.cpp @@ -275,17 +275,11 @@ MockFb::~MockFb() MockDumbBuffer::MockDumbBuffer(MockGpu *gpu, uint32_t width, uint32_t height, uint32_t bpp) : handle(gpu->idCounter++) , pitch(width * ceil(bpp / 8.0)) - , size(height * pitch) - , data(malloc(size)) + , data(height * pitch) , gpu(gpu) { } -MockDumbBuffer::~MockDumbBuffer() -{ - free(data); -} - // drm functions #define GPU(fd, error) auto gpu = getGpu(fd);\ @@ -352,7 +346,7 @@ int drmIoctl(int fd, unsigned long request, void *arg) auto dumb = std::make_shared(gpu, args->width, args->height, args->bpp); args->handle = dumb->handle; args->pitch = dumb->pitch; - args->size = dumb->size; + args->size = dumb->data.size(); gpu->dumbBuffers << dumb; return 0; } else if (request == DRM_IOCTL_MODE_DESTROY_DUMB) { @@ -372,7 +366,7 @@ int drmIoctl(int fd, unsigned long request, void *arg) qWarning("buffer %u not found!", args->handle); return -(errno = EINVAL); } else { - args->offset = reinterpret_cast((*it)->data); + args->offset = reinterpret_cast((*it)->data.data()); return 0; } } diff --git a/autotests/drm/mock_drm.h b/autotests/drm/mock_drm.h index 7358e27332..e20ca50a9b 100644 --- a/autotests/drm/mock_drm.h +++ b/autotests/drm/mock_drm.h @@ -137,12 +137,10 @@ public: class MockDumbBuffer { public: MockDumbBuffer(MockGpu *gpu, uint32_t width, uint32_t height, uint32_t bpp); - ~MockDumbBuffer(); uint32_t handle; uint32_t pitch; - uint64_t size; - void *data; + std::vector data; MockGpu *gpu; };