digitalmars.D.learn - hiding a pointer
- Thomas Kuehne (48/48) Oct 23 2006 -----BEGIN PGP SIGNED MESSAGE-----
-
Stewart Gordon
(13/19)
Oct 24 2006
- Thomas Kuehne (10/16) Oct 24 2006 -----BEGIN PGP SIGNED MESSAGE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Sometimes you might have to hide a pointer, so that the GC doesn't "see" it and might reclaim the pointer's destination if there are no other pointers into this area. XORing and other mathematical transformations aren't save(the result might look like a pointer into some other GC-controlled area). Using memory allocated by std.c.stdlib.malloc to store the pointer works, but will require you to call std.c.stdlib.free at some later point. As far as I am aware Linux and Windows never allocate user memory at 0x0000_00XX(32bit) or 0x0000_0000_0000_00XX(64bit): The above code should work regardless of endianess or pointer size. trivial usage sample: Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFFPcHMLK5blCcjpWoRAtk9AJ9obolpi2cPg0C55yjnHdAousvVaACfaZhf LTOod2fWIxnfSsT5AnOaLcQ= =b8dw -----END PGP SIGNATURE-----
Oct 23 2006
Thomas Kuehne wrote:-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Sometimes you might have to hide a pointer, so that the GC doesn't "see" it and might reclaim the pointer's destination if there are no other pointers into this area.<snip> And won't update it if it's moved by a copying GC. The only infallible solution I can see is if D finally gets weak references. Stewart. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d- s:- C++ a->--- UB P+ L E W++ N+++ o K- w++ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++++ h-- r-- !y ------END GEEK CODE BLOCK------ My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Oct 24 2006
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Stewart Gordon schrieb am 2006-10-24:Thomas Kuehne wrote:Right, this aint no weak pointer but a hidden one. Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFFPqFKLK5blCcjpWoRAtpLAKCjfjn+Gmrmy3hyDfpt3yThSnj2AwCfVOPC aegnJxYeIc+Jhz2AiGxJ2JY= =05o9 -----END PGP SIGNATURE-----Sometimes you might have to hide a pointer, so that the GC doesn't "see" it and might reclaim the pointer's destination if there are no other pointers into this area.<snip> And won't update it if it's moved by a copying GC.
Oct 24 2006