Accessors: Type safety

This commit is contained in:
shahramn 2024-02-25 15:56:00 +00:00
parent 8f31b29134
commit 1a1b446626
1 changed files with 1 additions and 2 deletions

View File

@ -477,14 +477,13 @@ static int pack_double_array_as_long(grib_accessor* a, const double* v, size_t*
{
grib_context* c = a->context;
int ret = GRIB_SUCCESS;
size_t i = 0;
size_t numBytes = *len * (sizeof(long));
long* lValues = (long*)grib_context_malloc(c, numBytes);
if (!lValues) {
grib_context_log(c, GRIB_LOG_ERROR, "Unable to allocate %ld bytes", numBytes);
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 */
ret = grib_pack_long(a, lValues, len);
grib_context_free(c, lValues);