Re:Let’s Stop Bashing C
by rrauenza on Friday December 02, 2016 @12:08PM
(#13090330)
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.
[ Parent
| on HN ]
> 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".
> 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.
I read it as integer arithmetic. It is semantically different from pointer arithmetic.
So it's turt^H^H^H^Hpointers all the way down?