Tips and Tricks to avoid memory leaks in writing C

https://news.ycombinator.com/item?id=2648436
by naughtysriram • 15 years ago
5 4 15 years ago

When I write C I used to prototype the model first, then fix the memory leaks. I think its OK for throw code. I find that these leaks are mostly due to patterns of code that one avoids.

Like,

1. not assigning null to a pointer after freeing it

2. not allocating enough memory for string processing

Please throw in your tips and tricks to avoid memory leaks and memory related problems.

Related Stories

Loading related stories...

Source preview

news.ycombinator.com