[SDL] sdl freesurface causing seg faults when blitting.

Edward A Cullen eac203 at ecs.soton.ac.uk
Tue Mar 4 03:40:40 PST 2008


Hi,

Are you trying to use this with the main drawing surface returned by 
SDL_SetVideoMode()?

If so, that is why you are seg faulting.

Eddy

Kevron Rees wrote:
> int 
> gfxengine_sdl::drawRect(int 
> id)
> {
>>>  
>   
>  
> if(id==-1)return 
> -1;
>>>  
>   
>  
> if(surfaces[id].s==NULL) 
> return 
> -1;
>>>  
>   
>  
> SDL_BlitSurface(surfaces[id].s,NULL,screen,&surfaces[id].coords);  
>   
>   
>   
> //seg 
> faults 
> here!!!
>>>  
>   
>  
> return 
> 1;
> }
>> Are 
> you 
> certain 
> '&surface[id].coords' 
> is 
> resolving 
> as 
> you 
> desire?
>> ???
> 
> yes, i thought that might be the issue also so I made coords.w and coords.h match the surface->w and h.  What gets me is the only change I have to make is to comment out the SDL_FreeSurface() line and bingo! it works.  
> 
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



More information about the SDL mailing list