From: Kartik Thakore Date: Fri, 23 Oct 2009 20:28:51 +0000 (-0400) Subject: Lots of fixes for SV hacking in get video driver for SDL::Video X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7fa192d462637ee37895bb48c4bdac6d8ef2c22e;p=sdlgit%2FSDL_perl.git Lots of fixes for SV hacking in get video driver for SDL::Video --- diff --git a/src/Core/Video.xs b/src/Core/Video.xs index b0f9d2b..29a18ee 100644 --- a/src/Core/Video.xs +++ b/src/Core/Video.xs @@ -40,16 +40,16 @@ video_get_video_info() OUTPUT: RETVAL -char * -video_video_driver_name( maxlen ) - int maxlen +SV * +video_video_driver_name( ) + CODE: - char* buffer = safemalloc(sizeof(char) * maxlen); - char* str = SvPV( newSVpvn( buffer , maxlen), maxlen ); - - RETVAL = (char* )SDL_VideoDriverName( str , maxlen); - sv_2mortal(buffer); - sv_2mortal(str); - + char buffer[1024]; + if ( SDL_VideoDriverName(buffer, 1024) != NULL ) + { + RETVAL = newSVpv(buffer, 0); + } + else + XSRETURN_UNDEF; OUTPUT: RETVAL diff --git a/t/core_video.t b/t/core_video.t index ed2e4d5..ffa642d 100644 --- a/t/core_video.t +++ b/t/core_video.t @@ -2,7 +2,7 @@ use strict; use SDL; use SDL::Config; - +use Devel::Peek; use Test::More; plan ( tests => 6 ); @@ -24,7 +24,12 @@ isa_ok(SDL::Video::get_video_surface(), 'SDL::Surface', 'Checking if we get a su isa_ok(SDL::Video::get_video_info(), 'SDL::VideoInfo', 'Checking if we get videoinfo ref back'); -pass 'This is your driver name: '.SDL::Video::video_driver_name(10); +my $driver_name = SDL::Video::video_driver_name(); + +pass 'This is your driver name: '.$driver_name; + +#Dump( $driver_name); + pass "Are we still alive?"; =skip