Commit b4af9f7b by Nicolas Capens

Fix memory leaks.

Change-Id: I668c4295fd13d028fa53f6aa75ac6c6d4c6de44f Reviewed-on: https://swiftshader-review.googlesource.com/4531Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent 9185981d
...@@ -56,7 +56,7 @@ Surface::Surface(const Display *display, const Config *config) : display(display ...@@ -56,7 +56,7 @@ Surface::Surface(const Display *display, const Config *config) : display(display
Surface::~Surface() Surface::~Surface()
{ {
deleteResources(); Surface::deleteResources();
} }
bool Surface::initialize() bool Surface::initialize()
...@@ -230,6 +230,11 @@ WindowSurface::WindowSurface(Display *display, const Config *config, EGLNativeWi ...@@ -230,6 +230,11 @@ WindowSurface::WindowSurface(Display *display, const Config *config, EGLNativeWi
frameBuffer = nullptr; frameBuffer = nullptr;
} }
WindowSurface::~WindowSurface()
{
WindowSurface::deleteResources();
}
bool WindowSurface::initialize() bool WindowSurface::initialize()
{ {
ASSERT(!frameBuffer && !backBuffer && !depthStencil); ASSERT(!frameBuffer && !backBuffer && !depthStencil);
...@@ -343,6 +348,11 @@ PBufferSurface::PBufferSurface(Display *display, const Config *config, EGLint wi ...@@ -343,6 +348,11 @@ PBufferSurface::PBufferSurface(Display *display, const Config *config, EGLint wi
this->largestPBuffer = largestPBuffer; this->largestPBuffer = largestPBuffer;
} }
PBufferSurface::~PBufferSurface()
{
PBufferSurface::deleteResources();
}
void PBufferSurface::swap() void PBufferSurface::swap()
{ {
// No effect // No effect
...@@ -355,4 +365,8 @@ EGLNativeWindowType PBufferSurface::getWindowHandle() const ...@@ -355,4 +365,8 @@ EGLNativeWindowType PBufferSurface::getWindowHandle() const
return 0; return 0;
} }
void PBufferSurface::deleteResources()
{
}
} }
...@@ -97,6 +97,7 @@ class WindowSurface : public Surface ...@@ -97,6 +97,7 @@ class WindowSurface : public Surface
{ {
public: public:
WindowSurface(Display *display, const egl::Config *config, EGLNativeWindowType window); WindowSurface(Display *display, const egl::Config *config, EGLNativeWindowType window);
~WindowSurface() override;
bool initialize() override; bool initialize() override;
...@@ -118,11 +119,15 @@ class PBufferSurface : public Surface ...@@ -118,11 +119,15 @@ class PBufferSurface : public Surface
{ {
public: public:
PBufferSurface(Display *display, const egl::Config *config, EGLint width, EGLint height, EGLenum textureFormat, EGLenum textureTarget, EGLBoolean largestPBuffer); PBufferSurface(Display *display, const egl::Config *config, EGLint width, EGLint height, EGLenum textureFormat, EGLenum textureTarget, EGLBoolean largestPBuffer);
~PBufferSurface() override;
bool isPBufferSurface() const override { return true; } bool isPBufferSurface() const override { return true; }
void swap() override; void swap() override;
EGLNativeWindowType getWindowHandle() const override; EGLNativeWindowType getWindowHandle() const override;
private:
void deleteResources() override;
}; };
} }
......
...@@ -30,6 +30,7 @@ namespace sw ...@@ -30,6 +30,7 @@ namespace sw
struct Registers struct Registers
{ {
Registers(); Registers();
virtual ~Registers() {};
Pointer<Byte> constants; Pointer<Byte> constants;
......
...@@ -200,11 +200,21 @@ namespace sw ...@@ -200,11 +200,21 @@ namespace sw
~RegisterArray() ~RegisterArray()
{ {
if(dynamic)
{
delete x;
delete y;
delete z;
delete w;
}
else
{
delete[] x; delete[] x;
delete[] y; delete[] y;
delete[] z; delete[] z;
delete[] w; delete[] w;
} }
}
Register operator[](int i) Register operator[](int i)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment