PDA

View Full Version : How to use the PSDL_Rect type



retrocoder
02-06-2010, 11:38 AM
I have created a PSDL_Rect object using the “new” command, can anyone tell me how to then free this object to release the memory. I’ve tried different methods but keep getting access violations.

dazappa
02-06-2010, 02:44 PM
(I use FPC's SDL units, so it's barely different)

You shouldn't (AFAIK) need to create or free a rect.

procedure useless;
var
r: TSDL_Rect;
begin
r.x := 0;
r.y := 0;
r.w := 100;
r.h := 100;
SDL_BlitSurface(img,nil,scr,@r);
end;

Keep in mind I haven't actually checked for memory leaks this way ;) but even the C++ SDL tutorials on the internet don't seem to bother creating or freeing the rects.

retrocoder
02-06-2010, 03:01 PM
I'm using the PSDR_Rect and not the TSDR_Rect. The one I use is a pointer to a rect so I create it by using "new". I'm guessing it should be freed but thanks for you reply.

JSoftware
02-06-2010, 04:01 PM
You should dispose it with the Dispose function, but really, why bother? :)

Why not use pointers to an automatically allocated TSDL_Rect?