mirror of https://github.com/ecmwf/eccodes.git
Debug: Add assert on result of calls
This commit is contained in:
parent
4e4ffc974d
commit
d0b4e1f0ea
|
@ -160,7 +160,6 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
self->vector = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++);
|
self->vector = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++);
|
||||||
|
|
||||||
va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector);
|
va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector);
|
||||||
v = (grib_accessor_abstract_long_vector*)va;
|
v = (grib_accessor_abstract_long_vector*)va;
|
||||||
|
|
||||||
|
@ -175,6 +174,7 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
|
||||||
static int unpack_long(grib_accessor* a, long* val, size_t* len)
|
static int unpack_long(grib_accessor* a, long* val, size_t* len)
|
||||||
{
|
{
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
|
int err = 0;
|
||||||
long* vector;
|
long* vector;
|
||||||
grib_accessor_long_vector* self = (grib_accessor_long_vector*)a;
|
grib_accessor_long_vector* self = (grib_accessor_long_vector*)a;
|
||||||
grib_accessor* va = NULL;
|
grib_accessor* va = NULL;
|
||||||
|
@ -184,9 +184,12 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
|
||||||
v = (grib_accessor_abstract_long_vector*)va;
|
v = (grib_accessor_abstract_long_vector*)va;
|
||||||
|
|
||||||
/*TODO implement the dirty mechanism to avoid to unpack every time */
|
/*TODO implement the dirty mechanism to avoid to unpack every time */
|
||||||
grib_get_size(grib_handle_of_accessor(a), self->vector, &size);
|
err = grib_get_size(grib_handle_of_accessor(a), self->vector, &size);
|
||||||
|
DebugAssert(!err);
|
||||||
|
DebugAssert(size > 0);
|
||||||
vector = (long*)grib_context_malloc(a->context, sizeof(long) * size);
|
vector = (long*)grib_context_malloc(a->context, sizeof(long) * size);
|
||||||
grib_unpack_long(va, vector, &size);
|
err = grib_unpack_long(va, vector, &size);
|
||||||
|
DebugAssert(!err);
|
||||||
grib_context_free(a->context, vector);
|
grib_context_free(a->context, vector);
|
||||||
|
|
||||||
*val = v->v[self->index];
|
*val = v->v[self->index];
|
||||||
|
|
Loading…
Reference in New Issue