Permalink
Browse files

fixed memleaks for SDL::AudioSpec, SDL::Pango::Context and SDL::TTF::…

…Font
  • Loading branch information...
1 parent 4f0335a commit 2ef331ea534c4f9b74c95dee4e30abcb83cff562 Tobias Leich committed Nov 12, 2010
Showing with 20 additions and 10 deletions.
  1. +4 −3 src/Core/objects/AudioSpec.xs
  2. +8 −3 src/Pango/objects/Context.xs
  3. +8 −4 src/TTF/objects/Font.xs
@@ -2,6 +2,7 @@
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
+#include "helper.h"
#ifndef aTHX_
#define aTHX_
@@ -159,7 +160,7 @@ audiospec_callback( audiospec, cb )
#endif
void
-audiospec_DESTROY(self)
- SDL_AudioSpec *self
+audiospec_DESTROY(bag)
+ SV *bag
CODE:
- safefree( (char *)self );
+ objDESTROY(bag, safefree);
@@ -2,11 +2,16 @@
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
+#include "helper.h"
#include <SDL.h>
#ifdef HAVE_SDL_PANGO
#include <SDL_Pango.h>
+void _free_context(void *object)
+{
+ SDLPango_FreeContext((SDLPango_Context *)object);
+}
#endif
MODULE = SDL::Pango::Context PACKAGE = SDL::Pango::Context PREFIX = context_
@@ -31,9 +36,9 @@ context_new(CLASS, ...)
RETVAL
void
-context_DESTROY(context)
- SDLPango_Context *context
+context_DESTROY(bag)
+ SV *bag
CODE:
- SDLPango_FreeContext(context);
+ objDESTROY(bag, _free_context);
#endif
View
@@ -2,6 +2,7 @@
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
+#include "helper.h"
#ifndef aTHX_
#define aTHX_
@@ -11,6 +12,10 @@
#include <SDL.h>
#ifdef HAVE_SDL_TTF
#include <SDL_ttf.h>
+void _free_font(void *object)
+{
+ TTF_CloseFont((TTF_Font *)object);
+}
#endif
@@ -35,11 +40,10 @@ ttf_font_new(CLASS, file, ptsize, index = 0)
OUTPUT:
RETVAL
-
void
-ttf_font_DESTROY(ttf_font)
- TTF_Font *ttf_font
+ttf_font_DESTROY(bag)
+ SV *bag
CODE:
- TTF_CloseFont(ttf_font);
+ objDESTROY(bag, _free_font);
#endif

0 comments on commit 2ef331e

Please sign in to comment.