GRIB-803: grib_index_release does not close the file

This commit is contained in:
Shahram Najm 2015-07-29 16:29:23 +01:00
parent cf155e26e5
commit 04c370da62
2 changed files with 475 additions and 468 deletions

View File

@ -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);
}

View File

@ -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;
}