Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 23 Oct 2012
Offline Last Active Oct 23 2012 07:21 AM

Topics I've Started

SDL_FreeSurface and segfault

23 October 2012 - 01:59 AM


I I have a verry bad problem.

In my draw.h :

[source lang="cpp"]class CDraw : public CGraphic{ public : // constructor CDraw(const float& coef_resol_);...private : SDL_Surface *destimg;}[/source]

In my draw.cpp :

[source lang="cpp"]CDraw::CDraw(const float& coef_resol_) : CGraphic({0, 0}, coef_resol_), texture(NULL), destimg(NULL) {}void CDraw::~CDraw() { if(surface) SDL_FreeSurface(surface);/* segfault with it :-( */ if(destimg) SDL_FreeSurface(destimg);}[/source]

Well in all lines in draw.cpp, i'm not working with destimg. i commented all destimg. I have only destimg(NULL) and if(destimg) SDL_FreeSurface(destimg);

With gdb, with a break point before the if(destimg) i have :

(gdb) print destimg
$2 = (SDL_Surface *) 0x766177

And next a SEGFAULT.

I don t understand, thanks