mirror of https://github.com/ecmwf/eccodes.git
Remove unused data members
This commit is contained in:
parent
9c83171076
commit
047c14ff82
|
@ -518,7 +518,6 @@ struct grib_nearest
|
||||||
{
|
{
|
||||||
grib_arguments* args; /** args of iterator */
|
grib_arguments* args; /** args of iterator */
|
||||||
grib_handle* h;
|
grib_handle* h;
|
||||||
grib_context* context;
|
|
||||||
double* values;
|
double* values;
|
||||||
size_t values_count;
|
size_t values_count;
|
||||||
grib_nearest_class* cclass;
|
grib_nearest_class* cclass;
|
||||||
|
|
|
@ -322,7 +322,7 @@ int grib_nearest_find_generic(
|
||||||
if ((ret = grib_nearest_get_radius(h, &radiusInKm)) != GRIB_SUCCESS)
|
if ((ret = grib_nearest_get_radius(h, &radiusInKm)) != GRIB_SUCCESS)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
neighbours = (PointStore*)grib_context_malloc(nearest->context, nvalues * sizeof(PointStore));
|
neighbours = (PointStore*)grib_context_malloc(h->context, nvalues * sizeof(PointStore));
|
||||||
for (i = 0; i < nvalues; ++i) {
|
for (i = 0; i < nvalues; ++i) {
|
||||||
neighbours[i].m_dist = 1e10; /* set all distances to large number to begin with */
|
neighbours[i].m_dist = 1e10; /* set all distances to large number to begin with */
|
||||||
neighbours[i].m_lat = 0;
|
neighbours[i].m_lat = 0;
|
||||||
|
@ -345,14 +345,14 @@ int grib_nearest_find_generic(
|
||||||
*out_lats_count = (int)nvalues;
|
*out_lats_count = (int)nvalues;
|
||||||
|
|
||||||
if (*out_lats)
|
if (*out_lats)
|
||||||
grib_context_free(nearest->context, *out_lats);
|
grib_context_free(h->context, *out_lats);
|
||||||
*out_lats = (double*)grib_context_malloc(nearest->context, nvalues * sizeof(double));
|
*out_lats = (double*)grib_context_malloc(h->context, nvalues * sizeof(double));
|
||||||
if (!*out_lats)
|
if (!*out_lats)
|
||||||
return GRIB_OUT_OF_MEMORY;
|
return GRIB_OUT_OF_MEMORY;
|
||||||
|
|
||||||
if (*out_lons)
|
if (*out_lons)
|
||||||
grib_context_free(nearest->context, *out_lons);
|
grib_context_free(h->context, *out_lons);
|
||||||
*out_lons = (double*)grib_context_malloc(nearest->context, nvalues * sizeof(double));
|
*out_lons = (double*)grib_context_malloc(h->context, nvalues * sizeof(double));
|
||||||
if (!*out_lons)
|
if (!*out_lons)
|
||||||
return GRIB_OUT_OF_MEMORY;
|
return GRIB_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
@ -418,7 +418,7 @@ int grib_nearest_find_generic(
|
||||||
|
|
||||||
/* GRIB_NEAREST_SAME_XXX not yet implemented */
|
/* GRIB_NEAREST_SAME_XXX not yet implemented */
|
||||||
if (!*out_distances) {
|
if (!*out_distances) {
|
||||||
*out_distances = (double*)grib_context_malloc(nearest->context, 4 * sizeof(double));
|
*out_distances = (double*)grib_context_malloc(h->context, 4 * sizeof(double));
|
||||||
}
|
}
|
||||||
(*out_distances)[0] = neighbours[0].m_dist;
|
(*out_distances)[0] = neighbours[0].m_dist;
|
||||||
(*out_distances)[1] = neighbours[1].m_dist;
|
(*out_distances)[1] = neighbours[1].m_dist;
|
||||||
|
|
|
@ -81,16 +81,15 @@ static int init(grib_nearest* nearest, grib_handle* h, grib_arguments* args)
|
||||||
self->radius = grib_arguments_get_name(h, args, self->cargs++);
|
self->radius = grib_arguments_get_name(h, args, self->cargs++);
|
||||||
nearest->values = NULL;
|
nearest->values = NULL;
|
||||||
|
|
||||||
nearest->context = h->context;
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int destroy(grib_nearest* nearest)
|
static int destroy(grib_nearest* nearest)
|
||||||
{
|
{
|
||||||
|
grib_context* c = grib_context_get_default();
|
||||||
if (nearest->values)
|
if (nearest->values)
|
||||||
grib_context_free(nearest->context, nearest->values);
|
grib_context_free(c, nearest->values);
|
||||||
grib_context_free(nearest->context, nearest);
|
grib_context_free(c, nearest);
|
||||||
return GRIB_SUCCESS;
|
return GRIB_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,11 +124,13 @@ static int find(grib_nearest* nearest, grib_handle* h,
|
||||||
static int destroy(grib_nearest* nearest)
|
static int destroy(grib_nearest* nearest)
|
||||||
{
|
{
|
||||||
grib_nearest_healpix* self = (grib_nearest_healpix*)nearest;
|
grib_nearest_healpix* self = (grib_nearest_healpix*)nearest;
|
||||||
if (self->lats) grib_context_free(nearest->context, self->lats);
|
grib_context* c = grib_context_get_default();
|
||||||
if (self->lons) grib_context_free(nearest->context, self->lons);
|
|
||||||
if (self->i) grib_context_free(nearest->context, self->i);
|
if (self->lats) grib_context_free(c, self->lats);
|
||||||
if (self->j) grib_context_free(nearest->context, self->j);
|
if (self->lons) grib_context_free(c, self->lons);
|
||||||
if (self->k) grib_context_free(nearest->context, self->k);
|
if (self->i) grib_context_free(c, self->i);
|
||||||
if (self->distances) grib_context_free(nearest->context, self->distances);
|
if (self->j) grib_context_free(c, self->j);
|
||||||
|
if (self->k) grib_context_free(c, self->k);
|
||||||
|
if (self->distances) grib_context_free(c, self->distances);
|
||||||
return GRIB_SUCCESS;
|
return GRIB_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,11 +122,13 @@ static int find(grib_nearest* nearest, grib_handle* h,
|
||||||
static int destroy(grib_nearest* nearest)
|
static int destroy(grib_nearest* nearest)
|
||||||
{
|
{
|
||||||
grib_nearest_lambert_azimuthal_equal_area* self = (grib_nearest_lambert_azimuthal_equal_area*)nearest;
|
grib_nearest_lambert_azimuthal_equal_area* self = (grib_nearest_lambert_azimuthal_equal_area*)nearest;
|
||||||
if (self->lats) grib_context_free(nearest->context, self->lats);
|
grib_context* c = grib_context_get_default();
|
||||||
if (self->lons) grib_context_free(nearest->context, self->lons);
|
|
||||||
if (self->i) grib_context_free(nearest->context, self->i);
|
if (self->lats) grib_context_free(c, self->lats);
|
||||||
if (self->j) grib_context_free(nearest->context, self->j);
|
if (self->lons) grib_context_free(c, self->lons);
|
||||||
if (self->k) grib_context_free(nearest->context, self->k);
|
if (self->i) grib_context_free(c, self->i);
|
||||||
if (self->distances) grib_context_free(nearest->context, self->distances);
|
if (self->j) grib_context_free(c, self->j);
|
||||||
|
if (self->k) grib_context_free(c, self->k);
|
||||||
|
if (self->distances) grib_context_free(c, self->distances);
|
||||||
return GRIB_SUCCESS;
|
return GRIB_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,11 +122,13 @@ static int find(grib_nearest* nearest, grib_handle* h,
|
||||||
static int destroy(grib_nearest* nearest)
|
static int destroy(grib_nearest* nearest)
|
||||||
{
|
{
|
||||||
grib_nearest_lambert_conformal* self = (grib_nearest_lambert_conformal*)nearest;
|
grib_nearest_lambert_conformal* self = (grib_nearest_lambert_conformal*)nearest;
|
||||||
if (self->lats) grib_context_free(nearest->context, self->lats);
|
grib_context* c = grib_context_get_default();
|
||||||
if (self->lons) grib_context_free(nearest->context, self->lons);
|
|
||||||
if (self->i) grib_context_free(nearest->context, self->i);
|
if (self->lats) grib_context_free(c, self->lats);
|
||||||
if (self->j) grib_context_free(nearest->context, self->j);
|
if (self->lons) grib_context_free(c, self->lons);
|
||||||
if (self->k) grib_context_free(nearest->context, self->k);
|
if (self->i) grib_context_free(c, self->i);
|
||||||
if (self->distances) grib_context_free(nearest->context, self->distances);
|
if (self->j) grib_context_free(c, self->j);
|
||||||
|
if (self->k) grib_context_free(c, self->k);
|
||||||
|
if (self->distances) grib_context_free(c, self->distances);
|
||||||
return GRIB_SUCCESS;
|
return GRIB_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ static int init(grib_nearest* nearest, grib_handle* h, grib_arguments* args)
|
||||||
self->j = (size_t*)grib_context_malloc(h->context, 2 * sizeof(size_t));
|
self->j = (size_t*)grib_context_malloc(h->context, 2 * sizeof(size_t));
|
||||||
if (!self->j)
|
if (!self->j)
|
||||||
return GRIB_OUT_OF_MEMORY;
|
return GRIB_OUT_OF_MEMORY;
|
||||||
self->k = (size_t*)grib_context_malloc(nearest->context, 4 * sizeof(size_t));
|
self->k = (size_t*)grib_context_malloc(h->context, 4 * sizeof(size_t));
|
||||||
if (!self->k)
|
if (!self->k)
|
||||||
return GRIB_OUT_OF_MEMORY;
|
return GRIB_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
@ -195,15 +195,15 @@ static int find_global(grib_nearest* nearest, grib_handle* h,
|
||||||
self->lats_count = n;
|
self->lats_count = n;
|
||||||
|
|
||||||
if (self->lats)
|
if (self->lats)
|
||||||
grib_context_free(nearest->context, self->lats);
|
grib_context_free(h->context, self->lats);
|
||||||
self->lats = (double*)grib_context_malloc(nearest->context,
|
self->lats = (double*)grib_context_malloc(h->context,
|
||||||
self->lats_count * sizeof(double));
|
self->lats_count * sizeof(double));
|
||||||
if (!self->lats)
|
if (!self->lats)
|
||||||
return GRIB_OUT_OF_MEMORY;
|
return GRIB_OUT_OF_MEMORY;
|
||||||
|
|
||||||
if (self->lons)
|
if (self->lons)
|
||||||
grib_context_free(nearest->context, self->lons);
|
grib_context_free(h->context, self->lons);
|
||||||
self->lons = (double*)grib_context_malloc(nearest->context,
|
self->lons = (double*)grib_context_malloc(h->context,
|
||||||
nearest->values_count * sizeof(double));
|
nearest->values_count * sizeof(double));
|
||||||
if (!self->lons)
|
if (!self->lons)
|
||||||
return GRIB_OUT_OF_MEMORY;
|
return GRIB_OUT_OF_MEMORY;
|
||||||
|
@ -300,7 +300,7 @@ static int find_global(grib_nearest* nearest, grib_handle* h,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!self->distances)
|
if (!self->distances)
|
||||||
self->distances = (double*)grib_context_malloc(nearest->context, 4 * sizeof(double));
|
self->distances = (double*)grib_context_malloc(h->context, 4 * sizeof(double));
|
||||||
if (!self->distances)
|
if (!self->distances)
|
||||||
return GRIB_OUT_OF_MEMORY;
|
return GRIB_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
@ -420,16 +420,17 @@ static int find_global(grib_nearest* nearest, grib_handle* h,
|
||||||
static int destroy(grib_nearest* nearest)
|
static int destroy(grib_nearest* nearest)
|
||||||
{
|
{
|
||||||
grib_nearest_latlon_reduced* self = (grib_nearest_latlon_reduced*)nearest;
|
grib_nearest_latlon_reduced* self = (grib_nearest_latlon_reduced*)nearest;
|
||||||
|
grib_context* c = grib_context_get_default();
|
||||||
if (self->lats)
|
if (self->lats)
|
||||||
grib_context_free(nearest->context, self->lats);
|
grib_context_free(c, self->lats);
|
||||||
if (self->lons)
|
if (self->lons)
|
||||||
grib_context_free(nearest->context, self->lons);
|
grib_context_free(c, self->lons);
|
||||||
if (self->j)
|
if (self->j)
|
||||||
grib_context_free(nearest->context, self->j);
|
grib_context_free(c, self->j);
|
||||||
if (self->k)
|
if (self->k)
|
||||||
grib_context_free(nearest->context, self->k);
|
grib_context_free(c, self->k);
|
||||||
if (self->distances)
|
if (self->distances)
|
||||||
grib_context_free(nearest->context, self->distances);
|
grib_context_free(c, self->distances);
|
||||||
|
|
||||||
return GRIB_SUCCESS;
|
return GRIB_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,11 +124,13 @@ static int find(grib_nearest* nearest, grib_handle* h,
|
||||||
static int destroy(grib_nearest* nearest)
|
static int destroy(grib_nearest* nearest)
|
||||||
{
|
{
|
||||||
grib_nearest_mercator* self = (grib_nearest_mercator*)nearest;
|
grib_nearest_mercator* self = (grib_nearest_mercator*)nearest;
|
||||||
if (self->lats) grib_context_free(nearest->context, self->lats);
|
grib_context* c = grib_context_get_default();
|
||||||
if (self->lons) grib_context_free(nearest->context, self->lons);
|
|
||||||
if (self->i) grib_context_free(nearest->context, self->i);
|
if (self->lats) grib_context_free(c, self->lats);
|
||||||
if (self->j) grib_context_free(nearest->context, self->j);
|
if (self->lons) grib_context_free(c, self->lons);
|
||||||
if (self->k) grib_context_free(nearest->context, self->k);
|
if (self->i) grib_context_free(c, self->i);
|
||||||
if (self->distances) grib_context_free(nearest->context, self->distances);
|
if (self->j) grib_context_free(c, self->j);
|
||||||
|
if (self->k) grib_context_free(c, self->k);
|
||||||
|
if (self->distances) grib_context_free(c, self->distances);
|
||||||
return GRIB_SUCCESS;
|
return GRIB_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,11 +122,13 @@ static int find(grib_nearest* nearest, grib_handle* h,
|
||||||
static int destroy(grib_nearest* nearest)
|
static int destroy(grib_nearest* nearest)
|
||||||
{
|
{
|
||||||
grib_nearest_polar_stereographic* self = (grib_nearest_polar_stereographic*)nearest;
|
grib_nearest_polar_stereographic* self = (grib_nearest_polar_stereographic*)nearest;
|
||||||
if (self->lats) grib_context_free(nearest->context, self->lats);
|
grib_context* c = grib_context_get_default();
|
||||||
if (self->lons) grib_context_free(nearest->context, self->lons);
|
|
||||||
if (self->i) grib_context_free(nearest->context, self->i);
|
if (self->lats) grib_context_free(c, self->lats);
|
||||||
if (self->j) grib_context_free(nearest->context, self->j);
|
if (self->lons) grib_context_free(c, self->lons);
|
||||||
if (self->k) grib_context_free(nearest->context, self->k);
|
if (self->i) grib_context_free(c, self->i);
|
||||||
if (self->distances) grib_context_free(nearest->context, self->distances);
|
if (self->j) grib_context_free(c, self->j);
|
||||||
|
if (self->k) grib_context_free(c, self->k);
|
||||||
|
if (self->distances) grib_context_free(c, self->distances);
|
||||||
return GRIB_SUCCESS;
|
return GRIB_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,7 @@ static int init(grib_nearest* nearest, grib_handle* h, grib_arguments* args)
|
||||||
self->rotated = -1;
|
self->rotated = -1;
|
||||||
if (!self->j)
|
if (!self->j)
|
||||||
return GRIB_OUT_OF_MEMORY;
|
return GRIB_OUT_OF_MEMORY;
|
||||||
self->k = (size_t*)grib_context_malloc(nearest->context, NUM_NEIGHBOURS * sizeof(size_t));
|
self->k = (size_t*)grib_context_malloc(h->context, NUM_NEIGHBOURS * sizeof(size_t));
|
||||||
if (!self->k)
|
if (!self->k)
|
||||||
return GRIB_OUT_OF_MEMORY;
|
return GRIB_OUT_OF_MEMORY;
|
||||||
grib_get_long(h, "global", &self->global);
|
grib_get_long(h, "global", &self->global);
|
||||||
|
@ -251,16 +251,14 @@ static int find_global(grib_nearest* nearest, grib_handle* h,
|
||||||
self->lats_count = n;
|
self->lats_count = n;
|
||||||
|
|
||||||
if (self->lats)
|
if (self->lats)
|
||||||
grib_context_free(nearest->context, self->lats);
|
grib_context_free(h->context, self->lats);
|
||||||
self->lats = (double*)grib_context_malloc(nearest->context,
|
self->lats = (double*)grib_context_malloc(h->context, self->lats_count * sizeof(double));
|
||||||
self->lats_count * sizeof(double));
|
|
||||||
if (!self->lats)
|
if (!self->lats)
|
||||||
return GRIB_OUT_OF_MEMORY;
|
return GRIB_OUT_OF_MEMORY;
|
||||||
|
|
||||||
if (self->lons)
|
if (self->lons)
|
||||||
grib_context_free(nearest->context, self->lons);
|
grib_context_free(h->context, self->lons);
|
||||||
self->lons = (double*)grib_context_malloc(nearest->context,
|
self->lons = (double*)grib_context_malloc(h->context, nearest->values_count * sizeof(double));
|
||||||
nearest->values_count * sizeof(double));
|
|
||||||
if (!self->lons)
|
if (!self->lons)
|
||||||
return GRIB_OUT_OF_MEMORY;
|
return GRIB_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
@ -321,12 +319,11 @@ static int find_global(grib_nearest* nearest, grib_handle* h,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!self->distances)
|
if (!self->distances)
|
||||||
self->distances = (double*)grib_context_malloc(nearest->context, NUM_NEIGHBOURS * sizeof(double));
|
self->distances = (double*)grib_context_malloc(h->context, NUM_NEIGHBOURS * sizeof(double));
|
||||||
if (!self->distances)
|
if (!self->distances)
|
||||||
return GRIB_OUT_OF_MEMORY;
|
return GRIB_OUT_OF_MEMORY;
|
||||||
|
|
||||||
grib_binary_search(self->lats, ilat - 1, inlat,
|
grib_binary_search(self->lats, ilat - 1, inlat, &(self->j[0]), &(self->j[1]));
|
||||||
&(self->j[0]), &(self->j[1]));
|
|
||||||
|
|
||||||
plsize = self->lats_count;
|
plsize = self->lats_count;
|
||||||
if ((err = grib_get_size(h, self->pl, &plsize)) != GRIB_SUCCESS)
|
if ((err = grib_get_size(h, self->pl, &plsize)) != GRIB_SUCCESS)
|
||||||
|
@ -522,16 +519,13 @@ static int find_global(grib_nearest* nearest, grib_handle* h,
|
||||||
static int destroy(grib_nearest* nearest)
|
static int destroy(grib_nearest* nearest)
|
||||||
{
|
{
|
||||||
grib_nearest_reduced* self = (grib_nearest_reduced*)nearest;
|
grib_nearest_reduced* self = (grib_nearest_reduced*)nearest;
|
||||||
if (self->lats)
|
grib_context* c = grib_context_get_default();
|
||||||
grib_context_free(nearest->context, self->lats);
|
|
||||||
if (self->lons)
|
if (self->lats) grib_context_free(c, self->lats);
|
||||||
grib_context_free(nearest->context, self->lons);
|
if (self->lons) grib_context_free(c, self->lons);
|
||||||
if (self->j)
|
if (self->j) grib_context_free(c, self->j);
|
||||||
grib_context_free(nearest->context, self->j);
|
if (self->k) grib_context_free(c, self->k);
|
||||||
if (self->k)
|
if (self->distances) grib_context_free(c, self->distances);
|
||||||
grib_context_free(nearest->context, self->k);
|
|
||||||
if (self->distances)
|
|
||||||
grib_context_free(nearest->context, self->distances);
|
|
||||||
|
|
||||||
return GRIB_SUCCESS;
|
return GRIB_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,6 +128,7 @@ static int find(grib_nearest* nearest, grib_handle* h,
|
||||||
double lat = 0, lon = 0;
|
double lat = 0, lon = 0;
|
||||||
const bool is_rotated = is_rotated_grid(h);
|
const bool is_rotated = is_rotated_grid(h);
|
||||||
double angleOfRotation = 0, southPoleLat = 0, southPoleLon = 0;
|
double angleOfRotation = 0, southPoleLat = 0, southPoleLon = 0;
|
||||||
|
grib_context* c = h->context;
|
||||||
|
|
||||||
while (inlon < 0)
|
while (inlon < 0)
|
||||||
inlon += 360;
|
inlon += 360;
|
||||||
|
@ -194,16 +195,14 @@ static int find(grib_nearest* nearest, grib_handle* h,
|
||||||
self->lats_count = n;
|
self->lats_count = n;
|
||||||
|
|
||||||
if (self->lats)
|
if (self->lats)
|
||||||
grib_context_free(nearest->context, self->lats);
|
grib_context_free(c, self->lats);
|
||||||
self->lats = (double*)grib_context_malloc(nearest->context,
|
self->lats = (double*)grib_context_malloc(c, self->lats_count * sizeof(double));
|
||||||
self->lats_count * sizeof(double));
|
|
||||||
if (!self->lats)
|
if (!self->lats)
|
||||||
return GRIB_OUT_OF_MEMORY;
|
return GRIB_OUT_OF_MEMORY;
|
||||||
|
|
||||||
if (self->lons)
|
if (self->lons)
|
||||||
grib_context_free(nearest->context, self->lons);
|
grib_context_free(c, self->lons);
|
||||||
self->lons = (double*)grib_context_malloc(nearest->context,
|
self->lons = (double*)grib_context_malloc(c, self->lons_count * sizeof(double));
|
||||||
self->lons_count * sizeof(double));
|
|
||||||
if (!self->lons)
|
if (!self->lons)
|
||||||
return GRIB_OUT_OF_MEMORY;
|
return GRIB_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
@ -289,9 +288,9 @@ static int find(grib_nearest* nearest, grib_handle* h,
|
||||||
&(self->i[0]), &(self->i[1]));
|
&(self->i[0]), &(self->i[1]));
|
||||||
|
|
||||||
if (!self->distances)
|
if (!self->distances)
|
||||||
self->distances = (double*)grib_context_malloc(nearest->context, NUM_NEIGHBOURS * sizeof(double));
|
self->distances = (double*)grib_context_malloc(c, NUM_NEIGHBOURS * sizeof(double));
|
||||||
if (!self->k)
|
if (!self->k)
|
||||||
self->k = (size_t*)grib_context_malloc(nearest->context, NUM_NEIGHBOURS * sizeof(size_t));
|
self->k = (size_t*)grib_context_malloc(c, NUM_NEIGHBOURS * sizeof(size_t));
|
||||||
kk = 0;
|
kk = 0;
|
||||||
for (jj = 0; jj < 2; jj++) {
|
for (jj = 0; jj < 2; jj++) {
|
||||||
for (ii = 0; ii < 2; ii++) {
|
for (ii = 0; ii < 2; ii++) {
|
||||||
|
@ -310,7 +309,7 @@ static int find(grib_nearest* nearest, grib_handle* h,
|
||||||
* First unpack all the values into an array. Then when we need the 4 points
|
* First unpack all the values into an array. Then when we need the 4 points
|
||||||
* we just index into this array so no need to call grib_get_double_element_internal
|
* we just index into this array so no need to call grib_get_double_element_internal
|
||||||
*
|
*
|
||||||
* if (nearest->values) grib_context_free(nearest->context,nearest->values);
|
* if (nearest->values) grib_context_free(c,nearest->values);
|
||||||
* nearest->values = grib_context_malloc(h->context,nvalues*sizeof(double));
|
* nearest->values = grib_context_malloc(h->context,nvalues*sizeof(double));
|
||||||
* if (!nearest->values) return GRIB_OUT_OF_MEMORY;
|
* if (!nearest->values) return GRIB_OUT_OF_MEMORY;
|
||||||
* ret = grib_get_double_array(h, self->values_key, nearest->values ,&nvalues);
|
* ret = grib_get_double_array(h, self->values_key, nearest->values ,&nvalues);
|
||||||
|
@ -362,17 +361,13 @@ static int find(grib_nearest* nearest, grib_handle* h,
|
||||||
static int destroy(grib_nearest* nearest)
|
static int destroy(grib_nearest* nearest)
|
||||||
{
|
{
|
||||||
grib_nearest_regular* self = (grib_nearest_regular*)nearest;
|
grib_nearest_regular* self = (grib_nearest_regular*)nearest;
|
||||||
if (self->lats)
|
grib_context* c = grib_context_get_default();
|
||||||
grib_context_free(nearest->context, self->lats);
|
|
||||||
if (self->lons)
|
if (self->lats) grib_context_free(c, self->lats);
|
||||||
grib_context_free(nearest->context, self->lons);
|
if (self->lons) grib_context_free(c, self->lons);
|
||||||
if (self->i)
|
if (self->i) grib_context_free(c, self->i);
|
||||||
grib_context_free(nearest->context, self->i);
|
if (self->j) grib_context_free(c, self->j);
|
||||||
if (self->j)
|
if (self->k) grib_context_free(c, self->k);
|
||||||
grib_context_free(nearest->context, self->j);
|
if (self->distances) grib_context_free(c, self->distances);
|
||||||
if (self->k)
|
|
||||||
grib_context_free(nearest->context, self->k);
|
|
||||||
if (self->distances)
|
|
||||||
grib_context_free(nearest->context, self->distances);
|
|
||||||
return GRIB_SUCCESS;
|
return GRIB_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,11 +122,13 @@ static int find(grib_nearest* nearest, grib_handle* h,
|
||||||
static int destroy(grib_nearest* nearest)
|
static int destroy(grib_nearest* nearest)
|
||||||
{
|
{
|
||||||
grib_nearest_space_view* self = (grib_nearest_space_view*)nearest;
|
grib_nearest_space_view* self = (grib_nearest_space_view*)nearest;
|
||||||
if (self->lats) grib_context_free(nearest->context, self->lats);
|
grib_context* c = grib_context_get_default();
|
||||||
if (self->lons) grib_context_free(nearest->context, self->lons);
|
|
||||||
if (self->i) grib_context_free(nearest->context, self->i);
|
if (self->lats) grib_context_free(c, self->lats);
|
||||||
if (self->j) grib_context_free(nearest->context, self->j);
|
if (self->lons) grib_context_free(c, self->lons);
|
||||||
if (self->k) grib_context_free(nearest->context, self->k);
|
if (self->i) grib_context_free(c, self->i);
|
||||||
if (self->distances) grib_context_free(nearest->context, self->distances);
|
if (self->j) grib_context_free(c, self->j);
|
||||||
|
if (self->k) grib_context_free(c, self->k);
|
||||||
|
if (self->distances) grib_context_free(c, self->distances);
|
||||||
return GRIB_SUCCESS;
|
return GRIB_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue