mirror of https://github.com/ecmwf/eccodes.git
GRIB-803: grib_index_release does not close the file
This commit is contained in:
parent
cf155e26e5
commit
04c370da62
|
@ -407,11 +407,14 @@ void grib_file_delete(grib_file* file)
|
|||
GRIB_PTHREAD_ONCE(&once,&init);
|
||||
GRIB_MUTEX_LOCK(&mutex1);
|
||||
if (!file) return;
|
||||
if (file->handle) {
|
||||
if (fclose(file->handle) != 0) {
|
||||
perror(file->name);
|
||||
}
|
||||
}
|
||||
if (file->name) free(file->name);
|
||||
if (file->mode) free(file->mode);
|
||||
if (file->handle) {
|
||||
fclose(file->handle);
|
||||
}
|
||||
|
||||
if (file->buffer) {
|
||||
free(file->buffer);
|
||||
}
|
||||
|
|
|
@ -949,6 +949,7 @@ int _codes_index_add_file(grib_index* index,const char* filename,int message_typ
|
|||
newfile=(grib_file*)grib_context_malloc_clear(c,sizeof(grib_file));
|
||||
newfile->id=grib_filesid;
|
||||
newfile->name=strdup(file->name);
|
||||
newfile->handle = file->handle;
|
||||
index->files=newfile;
|
||||
} else {
|
||||
indfile=index->files;
|
||||
|
@ -962,6 +963,7 @@ int _codes_index_add_file(grib_index* index,const char* filename,int message_typ
|
|||
newfile=(grib_file*)grib_context_malloc_clear(c,sizeof(grib_file));
|
||||
newfile->id=grib_filesid;
|
||||
newfile->name=strdup(file->name);
|
||||
newfile->handle = file->handle;
|
||||
indfile->next=newfile;
|
||||
}
|
||||
|
||||
|
@ -1103,6 +1105,7 @@ int grib_index_add_file(grib_index* index, const char* filename)
|
|||
newfile=(grib_file*)grib_context_malloc_clear(c,sizeof(grib_file));
|
||||
newfile->id=grib_filesid;
|
||||
newfile->name=strdup(file->name);
|
||||
newfile->handle = file->handle;
|
||||
index->files=newfile;
|
||||
} else {
|
||||
indfile=index->files;
|
||||
|
@ -1116,6 +1119,7 @@ int grib_index_add_file(grib_index* index, const char* filename)
|
|||
newfile=(grib_file*)grib_context_malloc_clear(c,sizeof(grib_file));
|
||||
newfile->id=grib_filesid;
|
||||
newfile->name=strdup(file->name);
|
||||
newfile->handle = file->handle;
|
||||
indfile->next=newfile;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue