Performance: unpack_string: reduce scope and buffer size
@@ -350,7 +350,6 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
char* str = NULL;
char* p = 0;
size_t slen = 0;
- char sval[100] = {0,};
double dval = 0;
size_t dlen = 1;
@@ -358,6 +357,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
grib_context* c = a->context;
if (self->type != BUFR_DESCRIPTOR_TYPE_STRING) {
+ char sval[32] = {0,};
unpack_double(a, &dval, &dlen);
sprintf(sval, "%g", dval);
slen = strlen(sval);
@@ -383,7 +383,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
str = grib_context_strdup(c, self->stringValues->v[idx]->v[0]);
}
- if (str == 0 || strlen(str) == 0) {
+ if (str == NULL || strlen(str) == 0) {
grib_context_free(c, str);
*len = 0;
*val = 0;
