OnlineCop / kq-fork

Fork of KQ r910. Just for fun.
GNU General Public License v2.0
15 stars 9 forks source link

Zero memory leaks! #8

Open ghost opened 10 years ago

ghost commented 10 years ago

KQ v1.0 won't be released until there's absolutely zero memory leaks from KQ itself. Some libraries like Allegro and Lua may leak, but since theses aren't linked to KQ's source code, they won't be taken into account.

pedro-w commented 2 years ago

I've been compiling with -fsanitize=address on Linux for a while and this includes a leak checker phase. I am currently getting 37 bytes leaked from an allocation in SDL but the stack trace is incomplete so I can't see where or if the root cause is our code. I know 37 bytes is not "absolutely zero memory leaks" but we might give ourselves a pass on this one?

OnlineCop commented 2 years ago

Some locations we may need to look into are the C memory calls to malloc(), calloc(), memcpy(), memmove(), and memset() for a few things:

  1. They are not used on C++ objects, like std::string or std::vector which will cause issues when the destructor gets called twice.
  2. All malloc()/calloc() memory eventually gets freed (better yet: convert to smart pointers or vectors).
  3. C-style string manipulation functions strcpy(), strncpy(), strcat(), and strlen() are not being used on std::string types.