Any reason to prefer memset/ZeroMemory to value initialization for WinAPI structs?

前端 未结 7 841
南方客
南方客 2020-12-31 01:42

In Win32 programming a handful of POD structs is used. Those structs often need to be zeroed out before usage.

This can be done by calling memset()/

7条回答
  •  攒了一身酷
    2020-12-31 01:52

    In Win32, ZeroMemory is just a Macro around RtlZeroRemory, which is a macro to memset. So, I don't think it makes a difference.

    WinBase.h:

    \#define ZeroMemory RtlZeroMemory"
    

    WinNT.h:

    \#define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length))
    

提交回复
热议问题