Add C API functions to free memory for Template and TemplateList pointers