I read the following code fragment:
va_list args;
memset(&args, 0, sizeof(va_list));
va_start(args, xxx);
...
va_end(args);
What is the implication of memset()
here directly before va_start()
?
What is the difference if the memset()
line is removed?
The implication is that the programmer who wrote this does not know what they are doing, and enjoys wasting code.
They may be blindly following the directive of some static analysis tool that variables must be initialized before they are used.
va_start(args, xxx);
does all the necessary initialization, and overwrites all the 0-values that memset
just put in, making the work of memset
worthless.