News for hackers. Stuff that matters.
Re:Let’s Stop Bashing C by rrauenza on Friday December 02, 2016 @12:08PM (#13090330)

  >>> remembering to free(); not to free() twice;
  > You can set the pointer to NULL, then freeing again won't hurt
  >>> not to use after free()
  > Set the pointer to NULL so it will crash.
I like C and think it is bashed too much, but double frees and invalid pointers are most often the result of multiple copies of the pointer... some other structure hanging onto the original reference.
Re:Let’s Stop Bashing C by chelahmy on Friday December 02, 2016 @12:54PM (#13090734)
> some other structure hanging onto the original reference.

Let's unleash the superpower of C. You should've been using pointers to a pointer so that it is always a single reference to a memory block.

You can't really be programming in C if you're not thinking in pointers.

One more thing; The article should have mentioned "pointer increment" which has nothing to do with "+= 1".

Re:Let’s Stop Bashing C by kbp on Friday December 02, 2016 @02:24PM (#13091473)
> One more thing; The article should have mentioned "pointer increment" which has nothing to do with "+= 1".

What do you mean? ++ptr is perfectly equivalent to ptr += 1, for any pointer type.

Re:Let’s Stop Bashing C by chelahmy on Friday December 02, 2016 @03:47PM (#13092150)
I read it as integer arithmetic. It is semantically different from pointer arithmetic.
Re:Let’s Stop Bashing C by rrauenza on Friday December 02, 2016 @03:30PM (#13092018)
So it's turt^H^H^H^Hpointers all the way down?
Re:Let’s Stop Bashing C by chelahmy on Friday December 02, 2016 @04:06PM (#13092298)
Will the following help with the depth, or any depth?

  int *a, **b, **c, **d;

  d = c = b = &a;