News for hackers. Stuff that matters.
Re:Microsoft team submits Redis patch to enable Windows support by j_baker on Thursday December 08, 2011 @04:22PM (#3331191)
Correct me if I'm wrong, but casting the result of malloc is generally considered bad form in C, isn't it?
Re:Microsoft team submits Redis patch to enable Windows support by to3m on Thursday December 08, 2011 @04:33PM (#3331245)
In general, yes. For Win32, it is safe.

I would imagine they have activated "Compile as C++" for certain files. VC++ doesn't support C99, and it's probably easier to fix up any C++ incompatibilities than try to C89-ize everything.

Re:Microsoft team submits Redis patch to enable Windows support by unwind on Friday December 09, 2011 @07:49AM (#3333520)
http://stackoverflow.com/questions/605845/do-i-cast-the-resu... is a good place to start for a deeper discussion of this topic, if someone is interested.

My answer (obviously) is "yes", although as some folks point out here too, there are portability concerns that make it worth it sometimes.

Re:Microsoft team submits Redis patch to enable Windows support by jrockway on Thursday December 08, 2011 @04:29PM (#3331228)
I'm just assuming it's a Windowsism.
Re:Microsoft team submits Redis patch to enable Windows support by nknight on Thursday December 08, 2011 @08:36PM (#3332092)
I wouldn't so much call it "bad form" as just non-idiomatic. It doesn't really have big downsides in practice.

It's mostly a habit people pick up from C++ (where it's mandatory due to stricter typing), and if you want to build C code with a C++ compiler, you need to add the casts.

Given Microsoft's C++ fetish, I'm unsurprised by this.

Re:Microsoft team submits Redis patch to enable Windows support by mappu on Friday December 09, 2011 @12:19AM (#3332687)
I suppose one downside would be if you cast a voidptr to a pointer to (an element that has a different size), then calling operator++ moves it by more than if you had left it as a voidptr.