mirror of https://github.com/ecmwf/eccodes.git
Debugging: file pool contents
This commit is contained in:
parent
cae430a2c1
commit
9e4c44eddb
|
@ -486,6 +486,7 @@ void grib_file_close(const char* filename, int force, int* err);
|
|||
void grib_file_close_all(int* err);
|
||||
grib_file* grib_get_file(const char* filename, int* err);
|
||||
void grib_file_delete(grib_file* file);
|
||||
void grib_file_pool_print(const char* title, FILE* out);
|
||||
|
||||
/* grib_geography.cc */
|
||||
int grib_get_gaussian_latitudes(long trunc, double* lats);
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
*/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
#include <cstdio>
|
||||
|
||||
#define GRIB_MAX_OPENED_FILES 200
|
||||
|
||||
#if GRIB_PTHREADS
|
||||
|
@ -423,10 +425,22 @@ void grib_file_delete(grib_file* file)
|
|||
// }
|
||||
//}
|
||||
|
||||
free(file->name);
|
||||
free(file->mode);
|
||||
free(file->buffer);
|
||||
free(file->name); file->name = 0;
|
||||
free(file->mode); file->mode = 0;
|
||||
free(file->buffer); file->buffer = 0;
|
||||
grib_context_free(file->context, file);
|
||||
/* file = NULL; */
|
||||
GRIB_MUTEX_UNLOCK(&mutex1);
|
||||
}
|
||||
|
||||
void grib_file_pool_print(const char* title, FILE* out)
|
||||
{
|
||||
int i = 0;
|
||||
grib_file* file = file_pool.first;
|
||||
printf("%s: size=%zu, num_opened_files=%d\n", title, file_pool.size, file_pool.number_of_opened_files);
|
||||
while (file) {
|
||||
printf("%s:\tfile_pool entry %d = %s\n", title, i++, file->name);
|
||||
file = file->next;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
|
|
@ -855,6 +855,12 @@ static void test_grib_get_binary_scale_fact()
|
|||
Assert( result == 0 );
|
||||
}
|
||||
|
||||
static void test_filepool()
|
||||
{
|
||||
printf("Running %s ...\n", __func__);
|
||||
grib_file_pool_print("file_pool contents", stdout);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
printf("Doing unit tests. ecCodes version = %ld\n", grib_get_api_version());
|
||||
|
@ -924,6 +930,7 @@ int main(int argc, char** argv)
|
|||
test_grib2_choose_PDTN();
|
||||
test_codes_is_feature_enabled();
|
||||
test_codes_get_features();
|
||||
test_filepool();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue