Permalink
Browse files

using INT2PTR, to convert stored pointers to right size

  • Loading branch information...
1 parent 3e2cef5 commit b47d7d08736aa5632dd9cc6638c2e245e2814922 @FROGGS FROGGS committed Dec 30, 2011
Showing with 9 additions and 10 deletions.
  1. +1 −1 src/Core/Video.xs
  2. +1 −1 src/Core/objects/Event.xs
  3. +1 −2 src/Core/objects/Surface.xs
  4. +1 −1 src/GFX/FPSManager.xs
  5. +1 −1 src/SDLx/Timer.xs
  6. +2 −2 src/helper.h
  7. +2 −2 typemap
View
2 src/Core/Video.xs
@@ -159,7 +159,7 @@ video_update_rects ( surface, ... )
num_rects = items - 1;
rects = (SDL_Rect *)safemalloc(sizeof(SDL_Rect)*items);
for(i=0;i<num_rects;i++) {
- void** pointers = (void**)(SvIV((SV*)SvRV( ST(i+1) )));
+ void** pointers = (void**)INT2PTR(void *, SvIV((SV *)SvRV( ST(i + 1) )));
rects[i] = *(SDL_Rect *)(pointers[0]);
}
SDL_UpdateRects(surface,num_rects,rects);
View
2 src/Core/objects/Event.xs
@@ -966,7 +966,7 @@ event_DESTROY(bag)
SV* bag
CODE:
if( sv_isobject(bag) && (SvTYPE(SvRV(bag)) == SVt_PVMG) ) {
- void** pointers = (void**)(SvIV((SV*)SvRV( bag )));
+ void** pointers = (void**)INT2PTR(void *, SvIV((SV *)SvRV( bag )));
SDL_Event* self = (SDL_Event*)(pointers[0]);
if (PERL_GET_CONTEXT == pointers[1]) {
/*warn("Freed surface %p and pixels %p \n", surface, surface->pixels); */
View
3 src/Core/objects/Surface.xs
@@ -72,8 +72,7 @@ surface_new_from (CLASS, pixels, width, height, depth, pitch, Rmask = 0xFF000000
RETVAL = SDL_CreateRGBSurfaceFrom ( (void *)pix, width, height, depth, pitch, Rmask, Gmask, Bmask, Amask );
if( RETVAL == NULL)
croak ("SDL_CreateRGBSurfaceFrom failed: %s", SDL_GetError());
-
- OUTPUT:
+ OUTPUT:
RETVAL
View
2 src/GFX/FPSManager.xs
@@ -91,7 +91,7 @@ gfx_fps_DESTROY(bag)
SV *bag
CODE:
if( sv_isobject(bag) && (SvTYPE(SvRV(bag)) == SVt_PVMG) ) {
- void** pointers = (void**)(SvIV((SV*)SvRV( bag )));
+ void** pointers = (void**)INT2PTR(void *, SvIV((SV *)SvRV( bag )));
FPSmanager * fps = (FPSmanager*)(pointers[0]);
if (PERL_GET_CONTEXT == pointers[1]) {
pointers[0] = NULL;
View
2 src/SDLx/Timer.xs
@@ -140,7 +140,7 @@ timerx_DESTROY(bag)
SV *bag
CODE:
if( sv_isobject(bag) && (SvTYPE(SvRV(bag)) == SVt_PVMG) ) {
- void** pointers = (void**)(SvIV((SV*)SvRV( bag )));
+ void** pointers = (void**)INT2PTR(void *, SvIV((SV *)SvRV( bag )));
sdlx_timer * timer = (sdlx_timer*)(pointers[0]);
if (PERL_GET_CONTEXT == pointers[1]) {
pointers[0] = NULL;
View
4 src/helper.h
@@ -13,7 +13,7 @@ void *bag2obj( SV *bag )
if( sv_isobject(bag) && (SvTYPE(SvRV(bag)) == SVt_PVMG) )
{
- void **pointers = (void **)(SvIV((SV *)SvRV( bag )));
+ void **pointers = (void **)INT2PTR(void *, SvIV((SV *)SvRV( bag )));
obj = (void *)(pointers[0]);
}
@@ -53,7 +53,7 @@ void objDESTROY(SV *bag, void (* callback)(void *object))
{
if( sv_isobject(bag) && (SvTYPE(SvRV(bag)) == SVt_PVMG) )
{
- void** pointers = (void**)(SvIV((SV*)SvRV( bag )));
+ void** pointers = (void**)INT2PTR(void *, SvIV((SV *)SvRV( bag )));
void* object = pointers[0];
Uint32 *threadid = (Uint32*)(pointers[2]);
View
4 typemap
@@ -125,11 +125,11 @@ O_OBJECT
INPUT
O_OBJECT_NPGC
- $var = ($type) SvIV((SV*)SvRV($arg));
+ $var = INT2PTR($type, SvIV((SV *)SvRV( $arg )));
O_OBJECT
if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG) ) {
- void** pointers = (void**)(SvIV((SV*)SvRV( $arg )));
+ void** pointers = (void**)INT2PTR(void *, SvIV((SV *)SvRV( $arg )));
$var = ($type)(pointers[0]);
} else if ($arg == 0) {
XSRETURN(0);

0 comments on commit b47d7d0

Please sign in to comment.