mirror of https://github.com/ecmwf/eccodes.git
Dead code removal
This commit is contained in:
parent
e1ff5ef582
commit
917f3e655b
|
@ -443,8 +443,8 @@ grib_darray* grib_accessor_bufr_data_array_t::decode_double_array(grib_context*
|
|||
dval = GRIB_MISSING_DOUBLE;
|
||||
lval = 0;
|
||||
grib_context_log(c, GRIB_LOG_DEBUG, " modifiedWidth=%d lval=%ld dval=%g", modifiedWidth, lval, dval);
|
||||
ret = grib_darray_new(c, DYN_ARRAY_SIZE_INIT, DYN_ARRAY_SIZE_INCR);
|
||||
grib_darray_push(c, ret, dval);
|
||||
ret = grib_darray_new(DYN_ARRAY_SIZE_INIT, DYN_ARRAY_SIZE_INCR);
|
||||
grib_darray_push(ret, dval);
|
||||
*err = 0;
|
||||
return ret;
|
||||
}
|
||||
|
@ -452,15 +452,15 @@ grib_darray* grib_accessor_bufr_data_array_t::decode_double_array(grib_context*
|
|||
localReference = (long)lval + modifiedReference;
|
||||
localWidth = grib_decode_unsigned_long(data, pos, 6);
|
||||
grib_context_log(c, GRIB_LOG_DEBUG, "BUFR data decoding: \tlocalWidth=%d", localWidth);
|
||||
ret = grib_darray_new(c, numberOfSubsets_, 50);
|
||||
ret = grib_darray_new(numberOfSubsets_, 50);
|
||||
if (localWidth) {
|
||||
CHECK_END_DATA_RETURN(c, bd, this, localWidth * numberOfSubsets_, NULL);
|
||||
if (*err) {
|
||||
dval = GRIB_MISSING_DOUBLE;
|
||||
lval = 0;
|
||||
grib_context_log(c, GRIB_LOG_DEBUG, " modifiedWidth=%d lval=%ld dval=%g", modifiedWidth, lval, dval);
|
||||
ret = grib_darray_new(c, DYN_ARRAY_SIZE_INIT, DYN_ARRAY_SIZE_INCR);
|
||||
grib_darray_push(c, ret, dval);
|
||||
ret = grib_darray_new(DYN_ARRAY_SIZE_INIT, DYN_ARRAY_SIZE_INCR);
|
||||
grib_darray_push(ret, dval);
|
||||
*err = 0;
|
||||
return ret;
|
||||
}
|
||||
|
@ -472,7 +472,7 @@ grib_darray* grib_accessor_bufr_data_array_t::decode_double_array(grib_context*
|
|||
else {
|
||||
dval = ((long)lval + localReference) * modifiedFactor;
|
||||
}
|
||||
grib_darray_push(c, ret, dval);
|
||||
grib_darray_push(ret, dval);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -492,12 +492,12 @@ grib_darray* grib_accessor_bufr_data_array_t::decode_double_array(grib_context*
|
|||
if (bufr_multi_element_constant_arrays) {
|
||||
grib_context_log(c, GRIB_LOG_DEBUG, " modifiedWidth=%d lval=%ld dval=%g (const array multi values) %6.6ld", modifiedWidth, lval, dval, bd->code);
|
||||
for (j = 0; j < numberOfSubsets_; j++) {
|
||||
grib_darray_push(c, ret, dval);
|
||||
grib_darray_push(ret, dval);
|
||||
}
|
||||
}
|
||||
else {
|
||||
grib_context_log(c, GRIB_LOG_DEBUG, " modifiedWidth=%d lval=%ld dval=%g (const array single value) %6.6ld", modifiedWidth, lval, dval, bd->code);
|
||||
grib_darray_push(c, ret, dval);
|
||||
grib_darray_push(ret, dval);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -954,11 +954,11 @@ int decode_element(grib_context* c, grib_accessor_bufr_data_array_t* self, int s
|
|||
if (self->compressedData_) {
|
||||
err = self->decode_string_array(c, data, pos, bd);
|
||||
index = grib_vsarray_used_size(self->stringValues_);
|
||||
dar = grib_darray_new(c, self->numberOfSubsets_, 10);
|
||||
dar = grib_darray_new(self->numberOfSubsets_, 10);
|
||||
index = self->numberOfSubsets_ * (index - 1);
|
||||
for (ii = 1; ii <= self->numberOfSubsets_; ii++) {
|
||||
x = (index + ii) * 1000 + bd->width / 8;
|
||||
grib_darray_push(c, dar, x);
|
||||
grib_darray_push(dar, x);
|
||||
}
|
||||
grib_vdarray_push(c, self->numericValues_, dar);
|
||||
}
|
||||
|
@ -973,7 +973,7 @@ int decode_element(grib_context* c, grib_accessor_bufr_data_array_t* self, int s
|
|||
index += grib_sarray_used_size(self->stringValues_->v[ii]);
|
||||
}
|
||||
cdval = index * 1000 + bd->width / 8;
|
||||
grib_darray_push(c, dval, cdval);
|
||||
grib_darray_push(dval, cdval);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -996,7 +996,7 @@ int decode_element(grib_context* c, grib_accessor_bufr_data_array_t* self, int s
|
|||
cdval = self->decode_double_value(c, data, pos, bd, self->canBeMissing_[i], &err);
|
||||
grib_context_log(c, GRIB_LOG_DEBUG, "BUFR data decoding: \t %s = %g",
|
||||
bd->shortName, cdval);
|
||||
grib_darray_push(c, dval, cdval);
|
||||
grib_darray_push(dval, cdval);
|
||||
}
|
||||
}
|
||||
return err;
|
||||
|
@ -1049,20 +1049,20 @@ int decode_replication(grib_context* c, grib_accessor_bufr_data_array_t* self, i
|
|||
}
|
||||
}
|
||||
if (self->compressedData_) {
|
||||
dval = grib_darray_new(c, 1, 100);
|
||||
dval = grib_darray_new(1, 100);
|
||||
if (c->bufr_multi_element_constant_arrays) {
|
||||
long j;
|
||||
for (j = 0; j < self->numberOfSubsets_; j++) {
|
||||
grib_darray_push(c, dval, (double)(*numberOfRepetitions));
|
||||
grib_darray_push(dval, (double)(*numberOfRepetitions));
|
||||
}
|
||||
}
|
||||
else {
|
||||
grib_darray_push(c, dval, (double)(*numberOfRepetitions));
|
||||
grib_darray_push(dval, (double)(*numberOfRepetitions));
|
||||
}
|
||||
grib_vdarray_push(c, self->numericValues_, dval);
|
||||
}
|
||||
else {
|
||||
grib_darray_push(c, dval, (double)(*numberOfRepetitions));
|
||||
grib_darray_push(dval, (double)(*numberOfRepetitions));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -1079,10 +1079,10 @@ int grib_accessor_bufr_data_array_t::encode_new_bitmap(grib_context* c, grib_buf
|
|||
cdval = inputBitmap_[iInputBitmap_++];
|
||||
}
|
||||
if (compressedData_) {
|
||||
doubleValues = grib_darray_new(c, 1, 1);
|
||||
grib_darray_push(c, doubleValues, cdval);
|
||||
doubleValues = grib_darray_new(1, 1);
|
||||
grib_darray_push(doubleValues, cdval);
|
||||
err = encode_double_array(c, buff, pos, expanded_->v[idx], doubleValues);
|
||||
grib_darray_delete(c, doubleValues);
|
||||
grib_darray_delete(doubleValues);
|
||||
}
|
||||
else {
|
||||
err = encode_double_value(c, buff, pos, expanded_->v[idx], cdval);
|
||||
|
@ -1178,10 +1178,10 @@ int encode_new_element(grib_context* c, grib_accessor_bufr_data_array_t* self, i
|
|||
if (bd->code == 31031)
|
||||
return self->encode_new_bitmap(c, buff, pos, i);
|
||||
if (self->compressedData_) {
|
||||
grib_darray* doubleValues = grib_darray_new(c, 1, 1);
|
||||
grib_darray_push(c, doubleValues, cdval);
|
||||
grib_darray* doubleValues = grib_darray_new(1, 1);
|
||||
grib_darray_push(doubleValues, cdval);
|
||||
err = self->encode_double_array(c, buff, pos, bd, doubleValues);
|
||||
grib_darray_delete(c, doubleValues);
|
||||
grib_darray_delete(doubleValues);
|
||||
}
|
||||
else {
|
||||
err = self->encode_double_value(c, buff, pos, bd, cdval);
|
||||
|
@ -1641,12 +1641,12 @@ void grib_accessor_bufr_data_array_t::push_zero_element(grib_darray* dval)
|
|||
{
|
||||
grib_darray* d = 0;
|
||||
if (compressedData_) {
|
||||
d = grib_darray_new(context_, 1, 100);
|
||||
grib_darray_push(context_, d, 0);
|
||||
d = grib_darray_new(1, 100);
|
||||
grib_darray_push(d, 0);
|
||||
grib_vdarray_push(context_, numericValues_, d);
|
||||
}
|
||||
else {
|
||||
grib_darray_push(context_, dval, 0);
|
||||
grib_darray_push(dval, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2840,7 +2840,7 @@ int grib_accessor_bufr_data_array_t::process_elements(int flag, long onlySubset,
|
|||
if (flag != PROCESS_ENCODE) {
|
||||
elementsDescriptorsIndex = grib_iarray_new(c, DYN_ARRAY_SIZE_INIT, DYN_ARRAY_SIZE_INCR);
|
||||
if (!compressedData_) {
|
||||
dval = grib_darray_new(c, DYN_ARRAY_SIZE_INIT, DYN_ARRAY_SIZE_INCR);
|
||||
dval = grib_darray_new(DYN_ARRAY_SIZE_INIT, DYN_ARRAY_SIZE_INCR);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -324,11 +324,11 @@ int grib_accessor_bufr_data_element_t::pack_double(const double* val, size_t* le
|
|||
descriptors_->v[elementsDescriptorsIndex_->v[0]->v[index_]]->shortName, count, numberOfSubsets_);
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
}
|
||||
grib_darray_delete(context_, numericValues_->v[index_]);
|
||||
numericValues_->v[index_] = grib_darray_new(context_, count, 1);
|
||||
grib_darray_delete(numericValues_->v[index_]);
|
||||
numericValues_->v[index_] = grib_darray_new(count, 1);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
grib_darray_push(context_, numericValues_->v[index_], val[i]);
|
||||
grib_darray_push(numericValues_->v[index_], val[i]);
|
||||
|
||||
*len = count;
|
||||
}
|
||||
|
@ -353,11 +353,11 @@ int grib_accessor_bufr_data_element_t::pack_long(const long* val, size_t* len)
|
|||
descriptors_->v[elementsDescriptorsIndex_->v[0]->v[index_]]->shortName, count, numberOfSubsets_);
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
}
|
||||
grib_darray_delete(context_, numericValues_->v[index_]);
|
||||
numericValues_->v[index_] = grib_darray_new(context_, count, 1);
|
||||
grib_darray_delete(numericValues_->v[index_]);
|
||||
numericValues_->v[index_] = grib_darray_new(count, 1);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
grib_darray_push(context_, numericValues_->v[index_], val[i] == GRIB_MISSING_LONG ? GRIB_MISSING_DOUBLE : val[i]);
|
||||
grib_darray_push(numericValues_->v[index_], val[i] == GRIB_MISSING_LONG ? GRIB_MISSING_DOUBLE : val[i]);
|
||||
}
|
||||
*len = count;
|
||||
}
|
||||
|
|
|
@ -29,11 +29,11 @@ void grib_accessor_transient_darray_t::dump(grib_dumper* dumper)
|
|||
int grib_accessor_transient_darray_t::pack_double(const double* val, size_t* len)
|
||||
{
|
||||
if (arr_)
|
||||
grib_darray_delete(context_, arr_);
|
||||
arr_ = grib_darray_new(context_, *len, 10);
|
||||
grib_darray_delete(arr_);
|
||||
arr_ = grib_darray_new(*len, 10);
|
||||
|
||||
for (size_t i = 0; i < *len; i++)
|
||||
grib_darray_push(context_, arr_, val[i]);
|
||||
grib_darray_push(arr_, val[i]);
|
||||
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
@ -41,11 +41,11 @@ int grib_accessor_transient_darray_t::pack_double(const double* val, size_t* len
|
|||
int grib_accessor_transient_darray_t::pack_long(const long* val, size_t* len)
|
||||
{
|
||||
if (arr_)
|
||||
grib_darray_delete(context_, arr_);
|
||||
arr_ = grib_darray_new(context_, *len, 10);
|
||||
grib_darray_delete(arr_);
|
||||
arr_ = grib_darray_new(*len, 10);
|
||||
|
||||
for (size_t i = 0; i < *len; i++)
|
||||
grib_darray_push(context_, arr_, (double)val[i]);
|
||||
grib_darray_push(arr_, (double)val[i]);
|
||||
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ int grib_accessor_transient_darray_t::unpack_long(long* val, size_t* len)
|
|||
void grib_accessor_transient_darray_t::destroy(grib_context* c)
|
||||
{
|
||||
if (arr_)
|
||||
grib_darray_delete(context_, arr_);
|
||||
grib_darray_delete(arr_);
|
||||
grib_accessor_gen_t::destroy(c);
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ static void destroy(grib_context* context, grib_action* act)
|
|||
grib_action_set_darray* a = (grib_action_set_darray*)act;
|
||||
|
||||
grib_context_free_persistent(context, a->name);
|
||||
grib_darray_delete(context, a->darray);
|
||||
grib_darray_delete(a->darray);
|
||||
grib_context_free_persistent(context, act->name);
|
||||
grib_context_free_persistent(context, act->op);
|
||||
}
|
||||
|
|
|
@ -132,5 +132,5 @@ static void destroy(grib_context* context, grib_action* act)
|
|||
grib_action_transient_darray* a = (grib_action_transient_darray*)act;
|
||||
|
||||
grib_context_free_persistent(context, a->name);
|
||||
grib_darray_delete(context, a->darray);
|
||||
grib_darray_delete(a->darray);
|
||||
}
|
||||
|
|
|
@ -128,9 +128,9 @@ size_t grib_bufr_descriptors_array_used_size(bufr_descriptors_array* v);
|
|||
|
||||
/* grib_darray.cc */
|
||||
void grib_darray_print(const char* title, const grib_darray* darray);
|
||||
grib_darray* grib_darray_new(grib_context* c, size_t size, size_t incsize);
|
||||
grib_darray* grib_darray_push(grib_context* c, grib_darray* v, double val);
|
||||
void grib_darray_delete(grib_context* c, grib_darray* v);
|
||||
grib_darray* grib_darray_new(size_t size, size_t incsize);
|
||||
grib_darray* grib_darray_push(grib_darray* v, double val);
|
||||
void grib_darray_delete(grib_darray* v);
|
||||
int grib_darray_is_constant(grib_darray* v, double epsilon);
|
||||
size_t grib_darray_used_size(grib_darray* v);
|
||||
|
||||
|
|
|
@ -38,11 +38,10 @@ void grib_darray_print(const char* title, const grib_darray* darray)
|
|||
// return v;
|
||||
// }
|
||||
|
||||
grib_darray* grib_darray_new(grib_context* c, size_t size, size_t incsize)
|
||||
grib_darray* grib_darray_new(size_t size, size_t incsize)
|
||||
{
|
||||
grib_darray* v = NULL;
|
||||
if (!c)
|
||||
c = grib_context_get_default();
|
||||
grib_context* c = grib_context_get_default();
|
||||
v = (grib_darray*)grib_context_malloc_clear(c, sizeof(grib_darray));
|
||||
if (!v) {
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "%s: Unable to allocate %zu bytes", __func__, sizeof(grib_darray));
|
||||
|
@ -63,9 +62,7 @@ grib_darray* grib_darray_new(grib_context* c, size_t size, size_t incsize)
|
|||
static grib_darray* grib_darray_resize(grib_darray* v)
|
||||
{
|
||||
const size_t newsize = v->incsize + v->size;
|
||||
grib_context* c = v->context;
|
||||
if (!c)
|
||||
c = grib_context_get_default();
|
||||
grib_context* c = grib_context_get_default();
|
||||
|
||||
v->v = (double*)grib_context_realloc(c, v->v, newsize * sizeof(double));
|
||||
v->size = newsize;
|
||||
|
@ -77,12 +74,13 @@ static grib_darray* grib_darray_resize(grib_darray* v)
|
|||
return v;
|
||||
}
|
||||
|
||||
grib_darray* grib_darray_push(grib_context* c, grib_darray* v, double val)
|
||||
grib_darray* grib_darray_push(grib_darray* v, double val)
|
||||
{
|
||||
size_t start_size = 100;
|
||||
size_t start_incsize = 100;
|
||||
|
||||
if (!v)
|
||||
v = grib_darray_new(c, start_size, start_incsize);
|
||||
v = grib_darray_new(start_size, start_incsize);
|
||||
|
||||
if (v->n >= v->size)
|
||||
v = grib_darray_resize(v);
|
||||
|
@ -91,12 +89,11 @@ grib_darray* grib_darray_push(grib_context* c, grib_darray* v, double val)
|
|||
return v;
|
||||
}
|
||||
|
||||
void grib_darray_delete(grib_context* c, grib_darray* v)
|
||||
void grib_darray_delete(grib_darray* v)
|
||||
{
|
||||
if (!v)
|
||||
return;
|
||||
if (!c)
|
||||
c = grib_context_get_default();
|
||||
grib_context* c = grib_context_get_default();
|
||||
if (v->v)
|
||||
grib_context_free(c, v->v);
|
||||
grib_context_free(c, v);
|
||||
|
|
|
@ -99,7 +99,7 @@ void grib_vdarray_delete_content(grib_context* c, grib_vdarray* v)
|
|||
if (!c)
|
||||
c = grib_context_get_default();
|
||||
for (i = 0; i < v->n; i++) {
|
||||
grib_darray_delete(c, v->v[i]);
|
||||
grib_darray_delete(v->v[i]);
|
||||
v->v[i] = 0;
|
||||
}
|
||||
v->n = 0;
|
||||
|
|
|
@ -2387,25 +2387,25 @@ grib_yyreduce:
|
|||
|
||||
case 9: /* dvalues: FLOAT */
|
||||
#line 277 "griby.y"
|
||||
{ (grib_yyval.dvalue)=grib_darray_push(grib_parser_context,0,(grib_yyvsp[0].dval));}
|
||||
{ (grib_yyval.dvalue)=grib_darray_push(0,(grib_yyvsp[0].dval));}
|
||||
#line 2392 "y.tab.c"
|
||||
break;
|
||||
|
||||
case 10: /* dvalues: dvalues ',' FLOAT */
|
||||
#line 278 "griby.y"
|
||||
{ (grib_yyval.dvalue)=grib_darray_push(grib_parser_context,(grib_yyvsp[-2].dvalue),(grib_yyvsp[0].dval));}
|
||||
{ (grib_yyval.dvalue)=grib_darray_push((grib_yyvsp[-2].dvalue),(grib_yyvsp[0].dval));}
|
||||
#line 2398 "y.tab.c"
|
||||
break;
|
||||
|
||||
case 11: /* dvalues: INTEGER */
|
||||
#line 279 "griby.y"
|
||||
{ (grib_yyval.dvalue)=grib_darray_push(grib_parser_context,0,(grib_yyvsp[0].lval));}
|
||||
{ (grib_yyval.dvalue)=grib_darray_push(0,(grib_yyvsp[0].lval));}
|
||||
#line 2404 "y.tab.c"
|
||||
break;
|
||||
|
||||
case 12: /* dvalues: dvalues ',' INTEGER */
|
||||
#line 280 "griby.y"
|
||||
{ (grib_yyval.dvalue)=grib_darray_push(grib_parser_context,(grib_yyvsp[-2].dvalue),(grib_yyvsp[0].lval));}
|
||||
{ (grib_yyval.dvalue)=grib_darray_push((grib_yyvsp[-2].dvalue),(grib_yyvsp[0].lval));}
|
||||
#line 2410 "y.tab.c"
|
||||
break;
|
||||
|
||||
|
|
|
@ -274,10 +274,10 @@ all: empty { grib_parser_all_actions = 0;grib_parser_concept=0;
|
|||
empty:;
|
||||
|
||||
|
||||
dvalues: FLOAT { $$=grib_darray_push(grib_parser_context,0,$1);}
|
||||
| dvalues ',' FLOAT { $$=grib_darray_push(grib_parser_context,$1,$3);}
|
||||
| INTEGER { $$=grib_darray_push(grib_parser_context,0,$1);}
|
||||
| dvalues ',' INTEGER { $$=grib_darray_push(grib_parser_context,$1,$3);}
|
||||
dvalues: FLOAT { $$=grib_darray_push(0,$1);}
|
||||
| dvalues ',' FLOAT { $$=grib_darray_push($1,$3);}
|
||||
| INTEGER { $$=grib_darray_push(0,$1);}
|
||||
| dvalues ',' INTEGER { $$=grib_darray_push($1,$3);}
|
||||
;
|
||||
|
||||
svalues: STRING { $$=grib_sarray_push(grib_parser_context,0,$1);}
|
||||
|
|
|
@ -636,23 +636,23 @@ void test_darray()
|
|||
{
|
||||
printf("Running %s ...\n", __func__);
|
||||
grib_context* c = grib_context_get_default();
|
||||
grib_darray* a = grib_darray_new(c, 10, 10);
|
||||
grib_darray_push(c, a, 42.009);
|
||||
grib_darray_push(c, a, -1.11);
|
||||
grib_darray_push(c, a, 5099);
|
||||
grib_darray* a = grib_darray_new(10, 10);
|
||||
grib_darray_push(a, 42.009);
|
||||
grib_darray_push(a, -1.11);
|
||||
grib_darray_push(a, 5099);
|
||||
grib_darray_print("darray", a);
|
||||
|
||||
grib_darray* b = grib_darray_new(c, 5, 1);
|
||||
grib_darray_push(c, b, 8);
|
||||
grib_darray_push(c, b, 12);
|
||||
grib_darray* b = grib_darray_new(5, 1);
|
||||
grib_darray_push(b, 8);
|
||||
grib_darray_push(b, 12);
|
||||
|
||||
grib_vdarray* va = grib_vdarray_new(c, 1, 1);
|
||||
grib_vdarray_push(c, va, a);
|
||||
grib_vdarray_push(c, va, b);
|
||||
grib_vdarray_print("vdarray", va);
|
||||
|
||||
grib_darray_delete(c, a);
|
||||
grib_darray_delete(c, b);
|
||||
grib_darray_delete(a);
|
||||
grib_darray_delete(b);
|
||||
grib_vdarray_delete(c, va);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue