set struct in stack allocation to resolve error in valgrind