win: include "malloc.h"

As stated in malloc's docs[1], the malloc.h is required for using the
malloc function, and from malloc.h's source code (which can be found
under installed VS), malloc is defined as a macro that has different
behaviors under different configurations.

So using malloc without including malloc.h is very dangerous, for
certain build configurations crashes can happen when writing to memory
allocated by malloc.

[1]: https://msdn.microsoft.com/en-us/library/6ewkz86d.aspx

PR-URL: https://github.com/libuv/libuv/pull/395
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit is contained in:
Cheng Zhao 2015-06-10 21:29:48 +08:00 committed by Saúl Ibarra Corretgé
parent c619f37c39
commit c0c26a0f07

View File

@ -29,7 +29,9 @@
#include <stdlib.h> /* malloc */
#include <string.h> /* memset */
#if !defined(_WIN32)
#if defined(_WIN32)
# include <malloc.h> /* malloc */
#else
# include <net/if.h> /* if_nametoindex */
#endif