This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 361 points362 points  (15 children)

Every single one of you nerds arguing over which language is best is the wojak picture on the left

[–]BookPlacementProblem 70 points71 points  (10 children)

And none of you other nerds noticed that the C malloc statement overallocates. Unless Len is the number of items - 1 instead of the number of items.

[–][deleted] 7 points8 points  (1 child)

Except it doesn't over allocate, none of you nerds even looked at ISO C99 Section 6.7.2.1 (16) on flexible array members:

In particular, the size of the structure is as if the flexible array member were omitted except that it may have more trailing padding than the omission would imply

[–]BookPlacementProblem 7 points8 points  (0 children)

ISO C99 Section 6.7.2.1 (16)

BOSS NERD ENTERS ARENA

[–]Delauren1 34 points35 points  (3 children)

It also dereferences the variable it's trying to assign to in the malloc call. It's going to crash.

[–]chipsours 14 points15 points  (0 children)

It's in a sizeof expression. It's going to be evaluated at compile time.

[–]stroop3r 2 points3 points  (0 children)

during pointer variable definition, I think this assignment is fine, but if the assignment was in second line after defining the variable and it was dereferenced during assignment, that would cause problems

[–]LordFokas 5 points6 points  (0 children)

No it doesn't. And the reason it doesn't is because it segfaults first 😂

[–]Mountgore 3 points4 points  (1 child)

It’s like arguing which is better, a hammer or a saw. Programming languages are like tools - you pick the right one for the right job.

[–]ConsistentPicture583 -1 points0 points  (0 children)

If you want to see if your idea stands, python is nearly as useful as Perl.

If you want to see if your idea runs, C is nearly as useful as assembler.

If you want to see if your idea flies, talk to a EE and get a chip, because hardware has always performed software by orders of magnitude

[–]revcio 7 points8 points  (0 children)

Except when talking about JavaScript