Skip to content

Commit

Permalink
call stb image free in ragesurface destructor
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Dec 4, 2018
1 parent 23faeac commit 4930af5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
16 changes: 9 additions & 7 deletions src/RageSurface.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "global.h"
#include "global.h"
#include "RageSurface.h"
#include "RageUtil.h"

#include "../../extern/stb-master/stb_image.h"
#include <climits>

int32_t
Expand Down Expand Up @@ -135,8 +135,9 @@ RageSurfaceFormat::Equivalent(const RageSurfaceFormat& rhs) const

RageSurface::RageSurface()
{
pixels = NULL;
pixels = nullptr;
pixels_owned = true;
stb_loadpoint = false;
}

RageSurface::RageSurface(const RageSurface& cpy)
Expand All @@ -153,10 +154,11 @@ RageSurface::RageSurface(const RageSurface& cpy)
pixels = NULL;
}

RageSurface::~RageSurface()
{
if (pixels_owned)
delete[] pixels;
RageSurface::~RageSurface(){

if (pixels_owned) delete[] pixels;
if (stb_loadpoint)
stbi_image_free(pixels);
}

static int
Expand Down
4 changes: 2 additions & 2 deletions src/RageSurface.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* RageSurface - holds a simple 2d graphic surface */
/* RageSurface - holds a simple 2d graphic surface */

#ifndef RAGE_SURFACE_H
#define RAGE_SURFACE_H
Expand Down Expand Up @@ -84,9 +84,9 @@ struct RageSurfaceFormat
struct RageSurface
{
RageSurfaceFormat fmt;

uint8_t* pixels;
bool pixels_owned;
bool stb_loadpoint;
int32_t w, h, pitch;
int32_t flags;

Expand Down

0 comments on commit 4930af5

Please sign in to comment.