api_generator:cpp:fix memory leak