News for hackers. Stuff that matters.
Re:Reading the NSA’s codebase: LemonGraph review by kevin_thibedeau on Friday August 10, 2018 @11:59AM (#17734502)
The latter creates Heisenbugs if you change the type of x and don't track down every malloc to update the type. It is better to avoid using sizeof(typename) if possible.

Now the profligate use of leading underscores. That is an issue.

Re:Reading the NSA’s codebase: LemonGraph review by saagarjha on Friday August 10, 2018 @03:52PM (#17736264)
> Now the profligate use of leading underscores. That is an issue.

This is a pretty common way of shoehorning access control into languages that do support them natively.

Re:Reading the NSA’s codebase: LemonGraph review by kieckerjan on Friday August 10, 2018 @01:51PM (#17735386)
Good point about the type change risk. However, in this case that was obviously not the reason, since there is an explicit cast (although the compiler would prevent it from becoming a HB). His hand was forced by the pointer hiding in the typedef. As I see it, this code is half-way smart, which is worse than no-way smart. (KISS!)
Re:Reading the NSA’s codebase: LemonGraph review by posterboy on Friday August 10, 2018 @01:48PM (#17735350)
where's the difference if you put in the numbers by hand? Which numbers do you put in to avoid mentioning the size of the type?
Re:Reading the NSA’s codebase: LemonGraph review by kevin_thibedeau on Friday August 10, 2018 @03:03PM (#17735934)
You just feed sizeof the instance of the object you're allocating memory for. That entails funky pseudo-dereferences for pointers so the compiler doesn't give you the size of a pointer. It will look up the object's type and requisite size to fill in the argument to malloc(). If the object in question has an unknown type (maybe all you've got is a void *) then you will have to provide the size by other means.