Generator: Fixed memory leak due to missing free() after malloc() in get_configured_program()

We want to uniformly use C++ functionality, hence replaced malloc() with new and added the missing delete.