Error handling and initialisation

This commit is contained in:
Shahram Najm 2018-11-19 14:49:10 +00:00
parent 7c8238fb0e
commit caa7da7775
2 changed files with 28 additions and 34 deletions

View File

@ -195,7 +195,7 @@ static int unpack_string(grib_accessor*a , char* v, size_t *len)
unsigned mess_len;
unsigned char* mess;
unsigned char* p;
long offset,length;
long offset=0, length=0;
grib_string_list* blacklist=NULL;
grib_accessor* b=NULL;
int ret=0;
@ -213,7 +213,6 @@ static int unpack_string(grib_accessor*a , char* v, size_t *len)
if((ret = grib_expression_evaluate_long(grib_handle_of_accessor(a),self->length,&length))
!= GRIB_SUCCESS)
return ret;
mess=(unsigned char*)grib_context_malloc(a->context,length);
memcpy(mess,grib_handle_of_accessor(a)->buffer->data+offset,length);
mess_len=length;

View File

@ -163,6 +163,7 @@ static void init(grib_accessor* a,const long l, grib_arguments* c)
static int unpack_double (grib_accessor* a, double* val, size_t *len)
{
int err = 0;
size_t size=0;
double* stat;
grib_accessor_vector* self = (grib_accessor_vector*)a;
@ -179,18 +180,12 @@ static int unpack_double (grib_accessor* a, double* val, size_t *len)
if (va->dirty) {
grib_get_size(grib_handle_of_accessor(a),self->vector,&size);
stat=(double*)grib_context_malloc_clear(a->context,sizeof(double)*size);
grib_unpack_double(va,stat,&size);
err = grib_unpack_double(va,stat,&size);
grib_context_free(a->context,stat);
if (err) return err;
}
*val = v->v[self->index];
return GRIB_SUCCESS;
return err;
}