4 ms·
The 382th episode in which a rustacean blames C while he has only practised C++. 1. The (int PTR) cast of malloc() gives you away immediately. No cast in C. 2
by wott 9y ago
The 382th episode in which a rustacean blames C while he has only practised C++.
1. The (int PTR) cast of malloc() gives you away immediately. No cast in C.
2. > missing free on resize. When the resize occurs, we reassign vec->data without freeing the old data pointer, resulting in a memory leak.
Er... C has realloc() for that. Once again, you do delete() + new() only in C++, not in C.
BTW, you forgot other errors in your "C" program.
- irundebian 9y agoPlease don't be so arrogant. Post your github profile, and then we can see if you write code without bugs.
- dang 9y agoPlease don't post snarky dismissals here. Not cool, and you can make your substantive points without casting them that way. https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html