FreeBSD audio on cpan still fails. So fixed test to catch it better
[sdlgit/SDL_perl.git] / src / SDL.xs
index 5f73b68..07b3d0b 100644 (file)
@@ -1414,10 +1414,11 @@ void
 UpdateRects ( surface, ... )
        SDL_Surface *surface
        CODE:
-               SDL_Rect *rects, *temp;
+               SDL_Rect *rects, *oldrects, *temp;
                int num_rects,i;
                if ( items < 2 ) return;
-               num_rects = items - 1;  
+               num_rects = items - 1;
+               oldrects = rects;       
                rects = (SDL_Rect *)safemalloc(sizeof(SDL_Rect)*items);
                for(i=0;i<num_rects;i++) {
                        temp = (SDL_Rect *)SvIV(ST(i+1));
@@ -1428,6 +1429,7 @@ UpdateRects ( surface, ... )
                } 
                SDL_UpdateRects(surface,num_rects,rects);
                safefree(rects);
+               safefree(oldrects);
 
 int
 Flip ( surface )
@@ -2979,9 +2981,20 @@ TTFSizeText ( font, text )
        CODE:
                int w,h;
                RETVAL = newAV();
-               TTF_SizeText(font,text,&w,&h);
-               av_push(RETVAL,newSViv(w));
-               av_push(RETVAL,newSViv(h));
+               if(TTF_SizeText(font,text,&w,&h))
+               {
+                       av_push(RETVAL,newSViv(w));
+                       av_push(RETVAL,newSViv(h));
+                       sv_2mortal((SV*)RETVAL);
+               }
+               else
+               {
+                        printf("TTF error at TTFSizeText: %s \n", TTF_GetError()); 
+                        Perl_croak (aTHX_ "TTF error \n");     
+       
+               }
+               
+       
        OUTPUT:
                RETVAL
 
@@ -2992,11 +3005,18 @@ TTFSizeUTF8 ( font, text )
        CODE:
                int w,h;
                RETVAL = newAV();
-               TTF_SizeUTF8(font,text,&w,&h);
+               if(TTF_SizeUTF8(font,text,&w,&h))
+               {
                        av_push(RETVAL,newSViv(w));
                        av_push(RETVAL,newSViv(h));
-               
-               sv_2mortal((SV*)RETVAL);
+                       sv_2mortal((SV*)RETVAL);
+
+               }
+               else
+               {
+                       printf("TTF error at TTFSizeUTF8 with : %s \n", TTF_GetError());
+                       Perl_croak (aTHX_ "TTF error \n");
+               }
                
        OUTPUT:
                RETVAL
@@ -3008,9 +3028,19 @@ TTFSizeUNICODE ( font, text )
        CODE:
                int w,h;
                RETVAL = newAV();
-               TTF_SizeUNICODE(font,text,&w,&h);
-               av_push(RETVAL,newSViv(w));
-               av_push(RETVAL,newSViv(h));
+               if(TTF_SizeUNICODE(font,text,&w,&h))
+               {
+                       av_push(RETVAL,newSViv(w));
+                       av_push(RETVAL,newSViv(h));
+                       sv_2mortal((SV*)RETVAL);
+
+               }
+               else
+               {
+                       printf("TTF error at TTFSizeUNICODE : %s \n", TTF_GetError()); 
+                       Perl_croak (aTHX_ "TTF error \n");
+               }
+
        OUTPUT:
                RETVAL