[fpc-other] Microsoft to ban Memcpy() :)

Marco van de Voort marcov at stack.nl
Sat May 16 12:33:49 CEST 2009


In our previous episode, "Vinzent Höfler" said:
> > And of course, the move() procedure in FPC/TP/Delphi has exactly the  
> > same problems as memcpy() as far as bounds-unsafety is concerned (it's  
> > similar with fillchar/memset, indexbyte/memchr, etc).
> 
> True. But in contrast to C an average programmer doesn't need it very often. In Pascal there are easier ways to assign arrays to each other than doing a raw byte copy. ;)

Less, yes.
 
> But I still fail to see the advantage of
> 
> void * memcpy_s (       void * destination,
>                         size_t dest_size,
>                   const void * source,
>                         size_t num );
> 
> vs. the original:
> 
> void * memcpy (       void * destination,
>                 const void * source,
>                       size_t num );
> 
> Time will tell, if memcpy_s() is actually "safer". If the programmer didn't think about the destination buffer's size before, why should he now? :->

That's the feeling I had too. It will only matter in a very small number of
items, where the numbers are actually calculated on the spot in different
ways.


More information about the fpc-other mailing list