diff --git a/src/grib_filepool.c b/src/grib_filepool.c index d9bbe5101..4dc681354 100644 --- a/src/grib_filepool.c +++ b/src/grib_filepool.c @@ -255,6 +255,7 @@ grib_file* grib_file_open(const char* filename, const char* mode, int* err) GRIB_MUTEX_UNLOCK(&mutex1); return NULL; } + if (file->mode) free(file->mode); file->mode = strdup(mode); if (file_pool.context->io_buffer_size) { #ifdef POSIX_MEMALIGN diff --git a/tools/grib_tools.c b/tools/grib_tools.c index 385709282..cb74e1774 100644 --- a/tools/grib_tools.c +++ b/tools/grib_tools.c @@ -150,6 +150,14 @@ int grib_tool(int argc, char** argv) grib_context* c = grib_context_get_default(); global_options.context = c; + /* This is a consequence of ECC-440. + * We want to keep the output file(s) opened as various + * messages are appended to them. Otherwise they will be opened/closed + * multiple times. + */ + if (c->file_pool_max_opened_files == 0) + c->file_pool_max_opened_files = 200; + #ifdef ENABLE_FLOATING_POINT_EXCEPTIONS feenableexcept(FE_ALL_EXCEPT & ~FE_INEXACT); #endif