Refactoring C Code: Multi platform and Valgrind