Valgrind is going to justly grumble about copying uninitialized data.  You've initialized a sufficient set of the members that various functions can be used to fill in the rest, but there are other members (there may well be some implementation-specific ones, even).  This could be fixed by initializing <code> struct tm ret = { 0 }; </code> or avoided by taking a struct tm * parameter instead of returning a moderately large struct.