www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Where to start with SafeD?

reply solidstate1991 <laszloszeremi outlook.com> writes:
When I tried to apply to a position at Symmetry, I've got a 
criticism from Atila Neves that some of my code relied too much 
on memcpy, thus making it unsafe. After digging into std.array, I 
found some function that could possibly replace it to emulate 
writing in the middle of a file, but at least for VFile, I need 
some type agnostic solution. I don't think it would be an easy 
task to make CPUBLiT safe, unless I write a high-level wrapper 
for it that works with either array slices and/or on a per-image 
basis, but I don't have a need for such thing at the moment.
Feb 13
parent Mike Franklin <slavo5150 yahoo.com> writes:
On Wednesday, 13 February 2019 at 22:29:18 UTC, solidstate1991 
wrote:
 When I tried to apply to a position at Symmetry, I've got a 
 criticism from Atila Neves that some of my code relied too much 
 on memcpy, thus making it unsafe. After digging into std.array, 
 I found some function that could possibly replace it to emulate 
 writing in the middle of a file, but at least for VFile, I need 
 some type agnostic solution.
I don't understand your use case, but for me, I try not to escape the type system. Instead of using void*, I recommend templating. That is the approach I took here: https://github.com/JinShil/memcpyD It still does explicit casts to prevent code bloat, which is still escaping the type system, but at least it avoids pointer arithmetic. I'm not sure if that's helpful, but regardless, there it is. Mike
Feb 13