Object cleanup and weak references

Max Bolingbroke "batterseapower{no" at sp4/\\/\\}hotmail.com
Sat Oct 28 17:51:25 PDT 2006


Bill Baxter wrote:
> Maybe this message from a few days ago helps?
> http://www.digitalmars.com/d/archives/digitalmars/D/learn/5016.html
> It may require wrapping your SDL_Surfaces in wrapper objects, becuase 
> the above doesn't work with structs.
> 
> Something like:
> 
> class CSDL_Surface
> {
>   this(SDL_Surface *s) { surf = s; }
>   ~this() { SDL_FreeSurface(surf); }
>   SDL_Surface *surf;
> }
> Then you'll need to always use the class destructor to free surfaces too 
> to maintain 1-1 correspondence between live surfaces and objects.
> 
> Thomas is probably the only one who can say if it'll work or not, though.


Wow, I have no idea what that code is doing noodling around in Ds 
internals, but if it works I will be a very happy man. Unfortunately, my 
project fails to compile after adding this code:

F:\Programming\Current\Destroyed>bud main -cleanup -debug -g 
-I.\..\;D:\D\dmd\src\ext -of.\bin\Destroyed.exe -w
D:\D\dmd\src\phobos\internal\gc\gcx.d(42): module win32 cannot read file 
'win32.d'

Although it seems that win32.d lives in the same directory as gcx.d... 
can someone point out what newbie mistake am I making? :-)

Thanks a lot for your help Bill!

Max



More information about the Digitalmars-d-learn mailing list