In get_file_list you must allocate space for the name and copy them in
rather than using the value from the direntp.
From the man page for readdir:
The pointer returned by readdir() points to data which may
be overwritten by another call to readdir() on the same
directory stream.