[PATCH vkd3d 5/6] vkd3d-shader: Write the SM1 constant table.

Henri Verbeet hverbeet at gmail.com
Thu Apr 15 06:38:23 CDT 2021


On Thu, 15 Apr 2021 at 13:19, Giovanni Mascellani
<gmascellani at codeweavers.com> wrote:
> Il 14/04/21 14:57, Henri Verbeet ha scritto:
> > You pretty much never want to use strcpy(). In this particular case,
> > we already calculated the string length above, and could use memcpy().
>
> Why?
>
> In this case I agree, since you already know the length. But is there a
> general reason for not wanting to use strcpy?
>
Because there are broadly two categories of strcpy() usage:

  - The ones where you know the length of the string that you're
copying. In these cases you can simply use memcpy().
  - The ones where you don't know the length of the string you're
copying. These are unsafe, because the destination buffer may not be
large enough to contain a string of arbitrary length.

There are probably some cases where you know an upper bound instead of
an exact length, and using strcpy() kind of works out; hence the
"pretty much never" instead of just "never", although even in those
cases it may be somewhat questionable whether strcpy() is really worth
it.



More information about the wine-devel mailing list