GC-safe memory copying for D
Denis Shelomovskij
verylonglogin.reg at gmail.com
Fri Mar 2 06:13:00 PST 2012
Even `memcpy` is claimed dangerous at http://dlang.org/garbage.html
(because of possibility of moving GC, I suppose) but it just creates
false positives for GC. `memmove` can even temporary destroy pointers in
some overlapping cases like Google answer on "Lucky" `memmove source
code` request does.
So I reinvented the wheel and created GC-safe `memmove` analog called
`copyOverlapped` with comprehensive unittest coverage:
https://bitbucket.org/denis_sh/misc/src/tip/memutils.d
And I want this or such function to be included in druntime and be used
in Phobos because using `memcpy`/`memmove` when even `memcpy` is called
dangerous in docs looks incorrect and easily fixable.
P.S.
This post is inspired by bearophile's unanswered post titled "Regarding
a recent copy() fix" about really mysterious David Simcha's answer about
`memmove`
http://d.puremagic.com/issues/show_bug.cgi?id=7484#c2
More information about the Digitalmars-d
mailing list