mirror of https://github.com/ecmwf/eccodes.git
Accessors: Type safety
This commit is contained in:
parent
8f31b29134
commit
1a1b446626
|
@ -477,14 +477,13 @@ static int pack_double_array_as_long(grib_accessor* a, const double* v, size_t*
|
||||||
{
|
{
|
||||||
grib_context* c = a->context;
|
grib_context* c = a->context;
|
||||||
int ret = GRIB_SUCCESS;
|
int ret = GRIB_SUCCESS;
|
||||||
size_t i = 0;
|
|
||||||
size_t numBytes = *len * (sizeof(long));
|
size_t numBytes = *len * (sizeof(long));
|
||||||
long* lValues = (long*)grib_context_malloc(c, numBytes);
|
long* lValues = (long*)grib_context_malloc(c, numBytes);
|
||||||
if (!lValues) {
|
if (!lValues) {
|
||||||
grib_context_log(c, GRIB_LOG_ERROR, "Unable to allocate %ld bytes", numBytes);
|
grib_context_log(c, GRIB_LOG_ERROR, "Unable to allocate %ld bytes", numBytes);
|
||||||
return GRIB_OUT_OF_MEMORY;
|
return GRIB_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
for (i = 0; i < *len; i++)
|
for (size_t i = 0; i < *len; i++)
|
||||||
lValues[i] = (long)v[i]; /* convert from double to long */
|
lValues[i] = (long)v[i]; /* convert from double to long */
|
||||||
ret = grib_pack_long(a, lValues, len);
|
ret = grib_pack_long(a, lValues, len);
|
||||||
grib_context_free(c, lValues);
|
grib_context_free(c, lValues);
|
||||||
|
|
Loading…
Reference in New Issue