Why do ZeroMemory, etc. exist when there are memset, etc. already?

CannibalSmith picture CannibalSmith · Jun 14, 2010 · Viewed 24.7k times · Source

Why does ZeroMemory(), and similar calls exist in the Windows API when there are memset and related calls in the C standard library already? Which ones should I call? I can guess the answer is "depends". On what?

Answer

In silico picture In silico · Jun 14, 2010

In C and C++, ZeroMemory() and memset() are the exact same thing.

/* In winnt.h */
#define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length))

/* In winbase.h */
#define ZeroMemory RtlZeroMemory

Why use ZeroMemory() then? To make it obvious. But I prefer memset() in C or C++ programs.