News for hackers. Stuff that matters.
Re:Reading the NSA’s codebase: LemonGraph review by EpicEng on Friday August 10, 2018 @11:52AM (#17734428)
Why would that be? You don't cast the result of malloc in C. It's wholly unnecessary, adds clutter to the code, and potentially hides an error if you forgot to include stdlib.h.

So why would that be "the preferred way"? I've been writing C for some time and no one who knows C casts the return value of malloc.

Re:Reading the NSA’s codebase: LemonGraph review by optymizer on Friday August 10, 2018 @12:02PM (#17734523)
The parent comment was referring to the usage of sizeof().

Also, the fact that they cast the result of malloc makes me think they were using a C++ compiler, which will complain that there's no cast.

Re:Reading the NSA’s codebase: LemonGraph review by EpicEng on Friday August 10, 2018 @01:10PM (#17735065)
>The parent comment was referring to the usage of sizeof().

Ah ok, makes more sense in re-reading now. I was lazy and went off of a child comment.

>Also, the fact that they cast the result of malloc makes me think they were using a C++ compiler, which will complain that there's no cast.

Definitely could be that.

Re:Reading the NSA’s codebase: LemonGraph review by blattimwind on Friday August 10, 2018 @12:18PM (#17734658)
If you're compiling for C++, you should be using static_cast<> instead.