ECC-163 attribute change: no parent, handle direct access

This commit is contained in:
Enrico Fucile 2015-11-05 10:03:17 +00:00
parent e315921c4d
commit 67c2bcfd81
152 changed files with 780 additions and 734 deletions

View File

@ -110,7 +110,7 @@ static void remove_accessor(grib_accessor *a)
s = a->parent;
if (a->parent->h->use_trie && *(a->all_names[0]) != '_') {
id=grib_hash_keys_get_id(a->parent->h->context->keys,a->all_names[0]);
id=grib_hash_keys_get_id(a->context->keys,a->all_names[0]);
a->parent->h->accessors[id]=NULL;
}

View File

@ -106,15 +106,15 @@ static void rename_accessor(grib_accessor *a,char* name){
char* the_old=(char*)a->all_names[0];
if (a->parent->h->use_trie && *(a->all_names[0]) != '_') {
id=grib_hash_keys_get_id(a->parent->h->context->keys,a->all_names[0]);
id=grib_hash_keys_get_id(a->context->keys,a->all_names[0]);
a->parent->h->accessors[id]=NULL;
id=grib_hash_keys_get_id(a->parent->h->context->keys,name);
id=grib_hash_keys_get_id(a->context->keys,name);
a->parent->h->accessors[id]=a;
}
a->all_names[0]=grib_context_strdup_persistent(a->parent->h->context,name);
a->all_names[0]=grib_context_strdup_persistent(a->context,name);
a->name=a->all_names[0];
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG,"Renaming %s to %s",the_old,name);
/* grib_context_free(a->parent->h->context,the_old); */
grib_context_log(a->context,GRIB_LOG_DEBUG,"Renaming %s to %s",the_old,name);
/* grib_context_free(a->context,the_old); */
return;
}

View File

@ -34,7 +34,7 @@ void grib_accessor_dump(grib_accessor* a, grib_dumper* f)
int grib_pack_missing(grib_accessor* a)
{
grib_accessor_class *c = a->cclass;
/*grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
while(c)
{
if(c->pack_missing)
@ -50,7 +50,7 @@ int grib_pack_missing(grib_accessor* a)
int grib_pack_zero(grib_accessor* a)
{
grib_accessor_class *c = a->cclass;
/*grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
while(c)
{
if(c->clear)
@ -66,7 +66,7 @@ int grib_pack_zero(grib_accessor* a)
int grib_is_missing_internal(grib_accessor* a)
{
grib_accessor_class *c = a->cclass;
/*grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
while(c)
{
if(c->is_missing)
@ -81,7 +81,7 @@ int grib_is_missing_internal(grib_accessor* a)
int grib_pack_double(grib_accessor* a, const double* v, size_t *len )
{
grib_accessor_class *c = a->cclass;
/*grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
while(c)
{
if(c->pack_double)
@ -97,7 +97,7 @@ int grib_pack_double(grib_accessor* a, const double* v, size_t *len )
int grib_pack_expression(grib_accessor* a, grib_expression *e )
{
grib_accessor_class *c = a->cclass;
/*grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
while(c)
{
if(c->pack_expression)
@ -113,7 +113,7 @@ int grib_pack_expression(grib_accessor* a, grib_expression *e )
int grib_pack_string(grib_accessor* a, const char* v, size_t *len )
{
grib_accessor_class *c = a->cclass;
/*grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG, "(%s)%s is packing (string) %s",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?v:"(null)");*/
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (string) %s",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?v:"(null)");*/
while(c)
{
@ -130,7 +130,7 @@ int grib_pack_string(grib_accessor* a, const char* v, size_t *len )
int grib_pack_string_array(grib_accessor* a, const char** v, size_t *len )
{
grib_accessor_class *c = a->cclass;
/*grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG, "(%s)%s is packing (string) %s",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?v:"(null)");*/
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (string) %s",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?v:"(null)");*/
while(c)
{
if(c->pack_string_array)
@ -146,7 +146,7 @@ int grib_pack_string_array(grib_accessor* a, const char** v, size_t *len )
int grib_pack_long(grib_accessor* a,const long* v, size_t *len )
{
grib_accessor_class *c = a->cclass;
/*grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG, "(%s)%s is packing (long) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (long) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
while(c)
{
if(c->pack_long)
@ -162,7 +162,7 @@ int grib_pack_long(grib_accessor* a,const long* v, size_t *len )
int grib_pack_bytes(grib_accessor* a, const unsigned char* v, size_t *len )
{
grib_accessor_class *c = a->cclass;
/*grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG, "(%s)%s is packing (bytes) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (bytes) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
while(c)
{
if(c->pack_bytes)
@ -178,7 +178,7 @@ int grib_pack_bytes(grib_accessor* a, const unsigned char* v, size_t *len )
int grib_unpack_bytes(grib_accessor* a, unsigned char* v, size_t *len )
{
grib_accessor_class *c = a->cclass;
/*grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (bytes)",(a->parent->owner)?(a->parent->owner->name):"root", a->name ); */
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (bytes)",(a->parent->owner)?(a->parent->owner->name):"root", a->name ); */
while(c)
{
if(c->unpack_bytes)
@ -209,7 +209,7 @@ int grib_unpack_double_subarray(grib_accessor* a, double* v, size_t start, size_
int grib_unpack_double(grib_accessor* a, double* v, size_t *len )
{
grib_accessor_class *c = a->cclass;
/*grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (double)",(a->parent->owner)?(a->parent->owner->name):"root", a->name ); */
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (double)",(a->parent->owner)?(a->parent->owner->name):"root", a->name ); */
while(c)
{
if(c->unpack_double)
@ -239,7 +239,7 @@ int grib_unpack_double_element(grib_accessor* a, size_t i ,double* v )
int grib_unpack_string(grib_accessor* a, char* v, size_t *len )
{
grib_accessor_class *c = a->cclass;
/* grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (string)",(a->parent->owner)?(a->parent->owner->name):"root", a->name ); */
/* grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (string)",(a->parent->owner)?(a->parent->owner->name):"root", a->name ); */
while(c)
{
if(c->unpack_string)
@ -321,7 +321,7 @@ int grib_accessors_list_unpack_string(grib_accessors_list* al,char** val,size_t*
int grib_unpack_long(grib_accessor* a,long* v, size_t *len )
{
grib_accessor_class *c = a->cclass;
/*grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (long)",(a->parent->owner)?(a->parent->owner->name):"root", a->name ); */
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (long)",(a->parent->owner)?(a->parent->owner->name):"root", a->name ); */
while(c)
{
if(c->unpack_long)
@ -352,7 +352,7 @@ long grib_accessor_get_native_type(grib_accessor* a)
long grib_get_next_position_offset(grib_accessor* a)
{
grib_accessor_class *c = NULL;
/*grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG, "(%s)%s is checking next (long)",(a->parent->owner)?(a->parent->owner->name):"root", a->name ); */
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is checking next (long)",(a->parent->owner)?(a->parent->owner->name):"root", a->name ); */
if (a) c = a->cclass;
while(c)
@ -508,7 +508,7 @@ void grib_accessor_delete(grib_context *ct, grib_accessor* a)
grib_accessor* grib_accessor_clone(grib_accessor* a,grib_section* s,int* err)
{
grib_accessor_class *c = a->cclass;
grib_context* ct=a->parent->h->context;
grib_context* ct=a->context;
while(c)
{
grib_accessor_class *super = c->super ? *(c->super) : NULL;
@ -524,7 +524,7 @@ grib_accessor* grib_accessor_clone(grib_accessor* a,grib_section* s,int* err)
void grib_update_size(grib_accessor* a, size_t len )
{
grib_accessor_class *c = a->cclass;
/*grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
while(c)
{
if(c->update_size)
@ -556,7 +556,7 @@ int grib_nearest_smaller_value(grib_accessor* a,double val,double* nearest)
size_t grib_preferred_size(grib_accessor* a,int from_handle)
{
grib_accessor_class *c = a->cclass;
/*grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG, "(%s)%s is packing (long) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (long) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
while(c)
{
if(c->preferred_size)
@ -587,7 +587,7 @@ grib_accessor* grib_next_accessor(grib_accessor* a)
void grib_resize(grib_accessor* a,size_t new_size)
{
grib_accessor_class *c = a->cclass;
/*grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG, "(%s)%s is packing (long) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (long) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
while(c)
{
if(c->resize)
@ -669,13 +669,13 @@ int grib_accessor_add_attribute(grib_accessor* a,grib_accessor* attr)
if (_grib_accessor_get_attribute(a,attr->name,&id)) return GRIB_ATTRIBUTE_CLASH;
for (id=0;id<MAX_ACCESSOR_ATTRIBUTES;id++) {
if (a->attributes[id] == NULL) {
attr->parent=a->parent;
/* attr->parent=a->parent; */
a->attributes[id]=attr;
attr->parent_as_attribute=a;
if (a->same)
attr->same=_grib_accessor_get_attribute(a->same,attr->name,&idx);
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG,"added attribute %s->%s",a->name,attr->name);
grib_context_log(a->context,GRIB_LOG_DEBUG,"added attribute %s->%s",a->name,attr->name);
return GRIB_SUCCESS;
}
}
@ -687,7 +687,7 @@ int grib_accessor_replace_attribute(grib_accessor* a,grib_accessor* attr)
int id=0;
int idx=0;
if (_grib_accessor_get_attribute(a,attr->name,&id) != NULL) {
grib_accessor_delete(a->parent->h->context,a->attributes[id]);
grib_accessor_delete(a->context,a->attributes[id]);
a->attributes[id]=attr;
attr->parent_as_attribute=a;
if (a->same)
@ -702,7 +702,7 @@ int grib_accessor_delete_attribute(grib_accessor* a,const char* name)
{
int id=0;
if (_grib_accessor_get_attribute(a,name,&id) != NULL) {
grib_accessor_delete(a->parent->h->context,a->attributes[id]);
grib_accessor_delete(a->context,a->attributes[id]);
a->attributes[id]=NULL;
return GRIB_SUCCESS;
} else {
@ -753,10 +753,10 @@ grib_accessor* grib_accessor_get_attribute(grib_accessor* a,const char* name)
} else {
size_t size=p-name;
attribute_name=p+2;
basename=(char*)grib_context_malloc_clear(a->parent->h->context,size+1);
basename=(char*)grib_context_malloc_clear(a->context,size+1);
basename=(char*)memcpy(basename,name,size);
acc=_grib_accessor_get_attribute(a,basename,&index);
grib_context_free(a->parent->h->context,basename);
grib_context_free(a->context,basename);
if (acc) return grib_accessor_get_attribute(acc,attribute_name);
else return NULL;
}
@ -770,7 +770,7 @@ grib_accessors_list* grib_accessors_list_create(grib_context* c)
void grib_accessors_list_push(grib_accessors_list* al,grib_accessor* a)
{
grib_accessors_list* last;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
last=grib_accessors_list_last(al);
if (last && last->accessor) {

View File

@ -113,6 +113,8 @@ grib_accessor* grib_accessor_factory(grib_section* p, grib_action* creator,
a->all_name_spaces[0] = creator->name_space;
a->creator = creator;
a->context = p->h->context;
a->h = NULL;
a->next = NULL;
a->previous = NULL;
a->parent = p;
@ -200,7 +202,7 @@ void grib_push_accessor(grib_accessor* a, grib_block_of_accessors* l)
if (a->parent->h->use_trie) {
if (*(a->all_names[0]) != '_') {
id=grib_hash_keys_get_id(a->parent->h->context->keys,a->all_names[0]);
id=grib_hash_keys_get_id(a->context->keys,a->all_names[0]);
a->same=a->parent->h->accessors[id];
@ -241,12 +243,12 @@ int grib_section_adjust_sizes(grib_section* s,int update,int depth)
/* grib_section_adjust_sizes(grib_get_sub_section(a),update,depth+1); */
err = grib_section_adjust_sizes(a->sub_section,update,depth+1);
if (err) return err;
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG,"grib_section_adjust_sizes: %s %ld [len=%ld] (depth=%d)\n",a->name,(long)a->offset,(long)a->length,depth);
grib_context_log(a->context,GRIB_LOG_DEBUG,"grib_section_adjust_sizes: %s %ld [len=%ld] (depth=%d)\n",a->name,(long)a->offset,(long)a->length,depth);
l = a->length;
if(offset != a->offset) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"Offset mismatch %s A->offset %ld offset %ld\n",a->name,(long)a->offset, (long)offset);
a->offset = offset;
return GRIB_DECODING_ERROR;

View File

@ -301,7 +301,7 @@ static void computeDelayedReplication(grib_accessor_apply_operators* self,
static int apply_operators(grib_accessor* a) {
grib_accessor_apply_operators* self = (grib_accessor_apply_operators*)a;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
grib_handle* h=a->parent->h;
int useDefinedBitmap;
long* descriptors=0;
@ -617,14 +617,14 @@ static int unpack_string_array (grib_accessor* a, char** val, size_t *len)
grib_accessor_apply_operators* self = (grib_accessor_apply_operators*)a;
int ret=0;
int i=0;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
ret=apply_operators(a);
if (ret) return ret;
if(*len < self->expandedAOSize)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR,
grib_context_log(a->context, GRIB_LOG_ERROR,
" wrong size (%ld) for %s it contains %d values ",*len, a->name , self->expandedAOSize);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
@ -633,25 +633,25 @@ static int unpack_string_array (grib_accessor* a, char** val, size_t *len)
*len = self->expandedAOSize;
switch (self->index) {
case 0:
long_to_string(a->parent->h->context,self->expandedAO,self->expandedAOSize,val);
long_to_string(a->context,self->expandedAO,self->expandedAOSize,val);
break;
case 1:
long_to_string(a->parent->h->context,self->scaleAO,self->expandedAOSize,val);
long_to_string(a->context,self->scaleAO,self->expandedAOSize,val);
break;
case 2:
double_to_string(a->parent->h->context,self->referenceAO,self->expandedAOSize,val);
double_to_string(a->context,self->referenceAO,self->expandedAOSize,val);
break;
case 3:
long_to_string(a->parent->h->context,self->widthAO,self->expandedAOSize,val);
long_to_string(a->context,self->widthAO,self->expandedAOSize,val);
break;
case 4:
long_to_string(a->parent->h->context,self->bitmapNumber,self->expandedAOSize,val);
long_to_string(a->context,self->bitmapNumber,self->expandedAOSize,val);
break;
case 5:
long_to_string(a->parent->h->context,self->associatedBitmapNumber,self->expandedAOSize,val);
long_to_string(a->context,self->associatedBitmapNumber,self->expandedAOSize,val);
break;
case 6:
long_to_string(a->parent->h->context,self->associatedBitmapIndex,self->expandedAOSize,val);
long_to_string(a->context,self->associatedBitmapIndex,self->expandedAOSize,val);
break;
case 7:
for (i=0;i<self->expandedAOSize;i++)
@ -670,7 +670,7 @@ static int unpack_string_array (grib_accessor* a, char** val, size_t *len)
val[i]=grib_context_strdup(c,self->units[i]);
break;
case 11:
long_to_string(a->parent->h->context,self->associatedInfoNumber,self->expandedAOSize,val);
long_to_string(a->context,self->associatedInfoNumber,self->expandedAOSize,val);
break;
default:
Assert(0);
@ -690,7 +690,7 @@ static int unpack_long (grib_accessor* a, long* val, size_t *len)
if(*len < self->expandedAOSize)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR,
grib_context_log(a->context, GRIB_LOG_ERROR,
" wrong size (%ld) for %s it contains %d values ",*len, a->name , self->expandedAOSize);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
@ -740,7 +740,7 @@ static int unpack_double (grib_accessor* a, double* val, size_t *len)
if(*len < self->expandedAOSize)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR,
grib_context_log(a->context, GRIB_LOG_ERROR,
" wrong size (%ld) for %s it contains %d values ",*len, a->name , self->expandedAOSize);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
@ -799,7 +799,7 @@ static int value_count(grib_accessor* a,long* rlen)
ret=apply_operators(a);
if (ret) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"%s unable to compute size",a->name);
return ret;
}

View File

@ -137,7 +137,7 @@ static void init_class(grib_accessor_class* c)
static void init(grib_accessor* a, const long len , grib_arguments* arg )
{
grib_accessor_array* self = (grib_accessor_array*)a;
self->block = (grib_block_of_accessors*) grib_context_malloc_clear(a->parent->h->context,sizeof(grib_block_of_accessors));
self->block = (grib_block_of_accessors*) grib_context_malloc_clear(a->context,sizeof(grib_block_of_accessors));
a->length = 0;
}

View File

@ -166,7 +166,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t *len)
if(len[0] < (a->length+1))
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%d) for %s it contains %d values ", len[0], a->name , a->length+1 );
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%d) for %s it contains %d values ", len[0], a->name , a->length+1 );
len[0] = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -184,7 +184,7 @@ static int pack_string(grib_accessor* a, const char* val, size_t *len)
int i = 0;
if(len[0] > (a->length)+1)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "pack_string: Wrong size (%d) for %s it contains %d values ", len[0], a->name , a->length+1 );
grib_context_log(a->context, GRIB_LOG_ERROR, "pack_string: Wrong size (%d) for %s it contains %d values ", len[0], a->name , a->length+1 );
len[0] = 0;
return GRIB_BUFFER_TOO_SMALL;
}
@ -201,12 +201,12 @@ static int pack_string(grib_accessor* a, const char* val, size_t *len)
}
static int pack_long(grib_accessor* a, const long* v, size_t *len){
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR, " Should not pack %s as long", a->name);
grib_context_log(a->context,GRIB_LOG_ERROR, " Should not pack %s as long", a->name);
return GRIB_NOT_IMPLEMENTED;
}
static int pack_double(grib_accessor* a, const double*v, size_t *len){
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR, " Should not pack %s as double", a->name);
grib_context_log(a->context,GRIB_LOG_ERROR, " Should not pack %s as double", a->name);
return GRIB_NOT_IMPLEMENTED;
}
@ -232,7 +232,7 @@ static int unpack_long (grib_accessor* a, long* v, size_t *len){
*v = strtol(val,&last,10);
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG, " Casting string %s to long", a->name);
grib_context_log(a->context,GRIB_LOG_DEBUG, " Casting string %s to long", a->name);
return GRIB_SUCCESS;
}
@ -247,7 +247,7 @@ static int unpack_double (grib_accessor* a, double*v, size_t *len){
if(*last == 0)
{
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG, " Casting string %s to long", a->name);
grib_context_log(a->context,GRIB_LOG_DEBUG, " Casting string %s to long", a->name);
return GRIB_SUCCESS;
}
@ -275,7 +275,7 @@ static int compare(grib_accessor* a,grib_accessor* b) {
if (alen != blen) return GRIB_COUNT_MISMATCH;
aval=(char*)grib_context_malloc(a->parent->h->context,alen*sizeof(char));
aval=(char*)grib_context_malloc(a->context,alen*sizeof(char));
bval=(char*)grib_context_malloc(b->parent->h->context,blen*sizeof(char));
grib_unpack_string(a,aval,&alen);
@ -284,7 +284,7 @@ static int compare(grib_accessor* a,grib_accessor* b) {
retval = GRIB_SUCCESS;
if (strcmp(aval,bval)) retval = GRIB_STRING_VALUE_MISMATCH;
grib_context_free(a->parent->h->context,aval);
grib_context_free(a->context,aval);
grib_context_free(b->parent->h->context,bval);
return retval;

View File

@ -155,7 +155,7 @@ static int unpack_long (grib_accessor* a, long* val, size_t *len)
if(*len < 1)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "grib_accessor_bit : unpack_long : Wrong size for %s it contains %d values ", a->name , 1 );
grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_bit : unpack_long : Wrong size for %s it contains %d values ", a->name , 1 );
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -181,7 +181,7 @@ static int pack_long (grib_accessor* a, const long *val, size_t *len)
unsigned char *mdata = 0;
if(*len < 1)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "grib_accessor_bit : pack_long : At least one value to pack for %s", a->name );
grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_bit : pack_long : At least one value to pack for %s", a->name );
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -189,7 +189,7 @@ static int pack_long (grib_accessor* a, const long *val, size_t *len)
owner = grib_find_accessor(a->parent->h,ac->owner);
if(!owner){
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "grib_accessor_bit : Cannot get the owner %s for computing the bit value of %s ",ac->owner, a->name);
grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_bit : Cannot get the owner %s for computing the bit value of %s ",ac->owner, a->name);
*len = 0;
return GRIB_NOT_FOUND;
}

View File

@ -223,7 +223,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
if(*len < tlen)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , tlen );
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , tlen );
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -248,7 +248,7 @@ static int unpack_double (grib_accessor* a, double* val, size_t *len)
if(*len < tlen)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , tlen );
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , tlen );
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -282,7 +282,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t *len)
if(len[0] < (a->length))
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%d) for %s it contains %d values ", len[0], a->name , a->length );
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%d) for %s it contains %d values ", len[0], a->name , a->length );
len[0] = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -164,7 +164,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
size_t size=0;
int ret=0;
grib_accessor_bits_per_value* self= (grib_accessor_bits_per_value*)a;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
grib_handle* h=a->parent->h;
if ( (ret=grib_get_size(h,self->values,&size)) != GRIB_SUCCESS) return ret;

View File

@ -339,7 +339,7 @@ static long next_offset(grib_accessor* a){
static void update_size(grib_accessor* a,size_t s)
{
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG,"updating size of %s old %ld new %ld",a->name,a->length,s);
grib_context_log(a->context,GRIB_LOG_DEBUG,"updating size of %s old %ld new %ld",a->name,a->length,s);
a->length = s;
Assert(a->length>=0);
}
@ -372,11 +372,11 @@ static int get_descriptors(grib_accessor* a) {
grib_accessor_bufr_data *self =(grib_accessor_bufr_data*)a;
grib_accessor* expandedDescriptors=0;
grib_handle* h=a->parent->h;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
expandedDescriptors=grib_find_accessor(a->parent->h,self->expandedDescriptorsName);
if (!expandedDescriptors) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"unable to find accessor %s",self->expandedDescriptorsName);
return GRIB_NOT_FOUND;
}
@ -385,9 +385,9 @@ static int get_descriptors(grib_accessor* a) {
err=_grib_get_size(a->parent->h,expandedDescriptors,&(self->numberOfDescriptors));
if (err) return err;
self->expandedDescriptors=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*self->numberOfDescriptors);
self->expandedDescriptors=(long*)grib_context_malloc_clear(a->context,sizeof(long)*self->numberOfDescriptors);
if (!self->expandedDescriptors) {
grib_context_log(a->parent->h->context,GRIB_LOG_FATAL,
grib_context_log(a->context,GRIB_LOG_FATAL,
"unable to allocate %ld bytes",(long)(self->numberOfDescriptors));
return GRIB_OUT_OF_MEMORY;
}
@ -451,7 +451,7 @@ static void push_units_accessor(grib_section* section,grib_accessor* a,long grou
grib_accessor_bufr_data *self =(grib_accessor_bufr_data*)a;
grib_accessor* gaUnits=0;
grib_action creatorUnits = {0, };
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
if (self->units[i][0]=='C' && ( !strcmp(self->units[i],"CCITTIA5") ||
!strncmp(self->units[i],"COMMON",6)) )

View File

@ -322,7 +322,7 @@ static long next_offset(grib_accessor* a)
static void update_size(grib_accessor* a,size_t s)
{
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG,"updating size of %s old %ld new %ld",a->name,a->length,s);
grib_context_log(a->context,GRIB_LOG_DEBUG,"updating size of %s old %ld new %ld",a->name,a->length,s);
a->length = s;
Assert(a->length>=0);
}
@ -372,7 +372,7 @@ static int get_descriptors(grib_accessor* a)
grib_accessor_bufr_data_array *self =(grib_accessor_bufr_data_array*)a;
int ret=0,i,numberOfDescriptors;
grib_handle* h=a->parent->h;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
if (!self->expandedAccessor)
self->expandedAccessor=grib_find_accessor(a->parent->h,self->expandedDescriptorsName);
@ -918,7 +918,7 @@ static int build_bitmap(grib_accessor_bufr_data_array *self,unsigned char* data,
int i,localReference,width,bitmapEndElementsDescriptorsIndex;
long ppos,n;
grib_accessor* a=(grib_accessor*)self;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
bufr_descriptor** descriptors=self->expanded->v;
long* edi=elementsDescriptorsIndex->v;
int iel=grib_iarray_used_size(elementsDescriptorsIndex)-1;
@ -1012,7 +1012,7 @@ static void push_zero_element(grib_accessor_bufr_data_array* self,grib_darray* d
{
grib_darray* d=0;
grib_accessor* a=(grib_accessor*)self;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
if (self->compressedData) {
d=grib_darray_new(c,1,100);
grib_darray_push(c,d,0);
@ -1022,7 +1022,7 @@ static void push_zero_element(grib_accessor_bufr_data_array* self,grib_darray* d
}
}
static grib_accessor* create_attribute(char* name,grib_section* section,int type,char* sval,double dval,long lval,unsigned long flags)
static grib_accessor* create_attribute_variable(char* name,grib_section* section,int type,char* sval,double dval,long lval,unsigned long flags)
{
grib_accessor* a=NULL;
grib_action creator = {0, };
@ -1034,6 +1034,8 @@ static grib_accessor* create_attribute(char* name,grib_section* section,int type
creator.name=name;
a=grib_accessor_factory(section, &creator, 0, NULL);
a->parent=NULL;
a->h=section->h;
accessor_variable_set_type(a,type);
len=1;
switch (type) {
@ -1142,6 +1144,8 @@ static grib_accessor* create_accessor_from_descriptor(grib_accessor* a,grib_acce
operatorCreator.set = 0;
operatorCreator.name="operator";
if(attribute) DebugAssert(attribute->parent==NULL);
if (dump) {
creator.flags = GRIB_ACCESSOR_FLAG_DUMP;
operatorCreator.flags |= GRIB_ACCESSOR_FLAG_DUMP;
@ -1153,7 +1157,7 @@ static grib_accessor* create_accessor_from_descriptor(grib_accessor* a,grib_acce
switch (self->expanded->v[idx]->F) {
case 0:
case 1:
creator.name=grib_context_strdup(a->parent->h->context,self->expanded->v[idx]->shortName);
creator.name=grib_context_strdup(a->context,self->expanded->v[idx]->shortName);
elementAccessor = grib_accessor_factory(section, &creator, 0, NULL);
if (self->canBeMissing[idx]) elementAccessor->flags |= GRIB_ACCESSOR_FLAG_CAN_BE_MISSING;
accessor_bufr_data_element_set_index(elementAccessor,ide);
@ -1169,30 +1173,32 @@ static grib_accessor* create_accessor_from_descriptor(grib_accessor* a,grib_acce
self->expanded->v[idx]->a=elementAccessor;
if (attribute) {
attribute->parent=elementAccessor->parent;
/* attribute->parent=elementAccessor->parent; */
/*
for (i=0;i<MAX_ACCESSOR_ATTRIBUTES;i++) {
if (attribute->attributes[i]) attribute->attributes[i]->parent=elementAccessor->parent;
}
*/
grib_accessor_add_attribute(elementAccessor,attribute);
}
attribute=create_attribute("index",section,GRIB_TYPE_LONG,0,0,count,flags);
attribute=create_attribute_variable("index",section,GRIB_TYPE_LONG,0,0,count,flags);
grib_accessor_add_attribute(elementAccessor,attribute);
sprintf(code,"%06ld",self->expanded->v[idx]->code);
attribute=create_attribute("code",section,GRIB_TYPE_STRING,grib_context_strdup(a->parent->h->context,code),0,0,flags);
attribute=create_attribute_variable("code",section,GRIB_TYPE_STRING,grib_context_strdup(a->context,code),0,0,flags);
grib_accessor_add_attribute(elementAccessor,attribute);
attribute=create_attribute("units",section,GRIB_TYPE_STRING,self->expanded->v[idx]->units,0,0,GRIB_ACCESSOR_FLAG_DUMP);
attribute=create_attribute_variable("units",section,GRIB_TYPE_STRING,self->expanded->v[idx]->units,0,0,GRIB_ACCESSOR_FLAG_DUMP);
grib_accessor_add_attribute(elementAccessor,attribute);
attribute=create_attribute("scale",section,GRIB_TYPE_LONG,0,0,self->expanded->v[idx]->scale,flags);
attribute=create_attribute_variable("scale",section,GRIB_TYPE_LONG,0,0,self->expanded->v[idx]->scale,flags);
grib_accessor_add_attribute(elementAccessor,attribute);
attribute=create_attribute("reference",section,GRIB_TYPE_DOUBLE,0,self->expanded->v[idx]->reference,0,flags);
attribute=create_attribute_variable("reference",section,GRIB_TYPE_DOUBLE,0,self->expanded->v[idx]->reference,0,flags);
grib_accessor_add_attribute(elementAccessor,attribute);
attribute=create_attribute("width",section,GRIB_TYPE_LONG,0,0,self->expanded->v[idx]->width,flags);
attribute=create_attribute_variable("width",section,GRIB_TYPE_LONG,0,0,self->expanded->v[idx]->width,flags);
grib_accessor_add_attribute(elementAccessor,attribute);
break;
case 2:
@ -1210,18 +1216,18 @@ static grib_accessor* create_accessor_from_descriptor(grib_accessor* a,grib_acce
accessor_bufr_data_element_set_numberOfSubsets(elementAccessor,self->numberOfSubsets);
accessor_bufr_data_element_set_subsetNumber(elementAccessor,subset);
attribute=create_attribute("index",section,GRIB_TYPE_LONG,0,0,count,flags);
attribute=create_attribute_variable("index",section,GRIB_TYPE_LONG,0,0,count,flags);
grib_accessor_add_attribute(elementAccessor,attribute);
} else {
elementAccessor = grib_accessor_factory(section, &operatorCreator, 0, NULL);
accessor_variable_set_type(elementAccessor,GRIB_TYPE_LONG);
attribute=create_attribute("index",section,GRIB_TYPE_LONG,0,0,count,flags);
attribute=create_attribute_variable("index",section,GRIB_TYPE_LONG,0,0,count,flags);
grib_accessor_add_attribute(elementAccessor,attribute);
sprintf(code,"%06ld",self->expanded->v[idx]->code);
attribute=create_attribute("code",section,GRIB_TYPE_STRING,code,0,0,flags);
attribute=create_attribute_variable("code",section,GRIB_TYPE_STRING,code,0,0,flags);
grib_accessor_add_attribute(elementAccessor,attribute);
}
self->expanded->v[idx]->a=elementAccessor;
@ -1239,23 +1245,23 @@ static grib_accessor* create_accessor_from_descriptor(grib_accessor* a,grib_acce
accessor_bufr_data_element_set_numberOfSubsets(elementAccessor,self->numberOfSubsets);
accessor_bufr_data_element_set_subsetNumber(elementAccessor,subset);
attribute=create_attribute("index",section,GRIB_TYPE_LONG,0,0,count,flags);
attribute=create_attribute_variable("index",section,GRIB_TYPE_LONG,0,0,count,flags);
grib_accessor_add_attribute(elementAccessor,attribute);
sprintf(code,"%06ld",self->expanded->v[idx]->code);
attribute=create_attribute("code",section,GRIB_TYPE_STRING,code,0,0,flags);
attribute=create_attribute_variable("code",section,GRIB_TYPE_STRING,code,0,0,flags);
grib_accessor_add_attribute(elementAccessor,attribute);
attribute=create_attribute("units",section,GRIB_TYPE_STRING,self->expanded->v[idx]->units,0,0,GRIB_ACCESSOR_FLAG_DUMP);
attribute=create_attribute_variable("units",section,GRIB_TYPE_STRING,self->expanded->v[idx]->units,0,0,GRIB_ACCESSOR_FLAG_DUMP);
grib_accessor_add_attribute(elementAccessor,attribute);
attribute=create_attribute("scale",section,GRIB_TYPE_LONG,0,0,self->expanded->v[idx]->scale,flags);
attribute=create_attribute_variable("scale",section,GRIB_TYPE_LONG,0,0,self->expanded->v[idx]->scale,flags);
grib_accessor_add_attribute(elementAccessor,attribute);
attribute=create_attribute("reference",section,GRIB_TYPE_DOUBLE,0,self->expanded->v[idx]->reference,0,flags);
attribute=create_attribute_variable("reference",section,GRIB_TYPE_DOUBLE,0,self->expanded->v[idx]->reference,0,flags);
grib_accessor_add_attribute(elementAccessor,attribute);
attribute=create_attribute("width",section,GRIB_TYPE_LONG,0,0,self->expanded->v[idx]->width,flags);
attribute=create_attribute_variable("width",section,GRIB_TYPE_LONG,0,0,self->expanded->v[idx]->width,flags);
grib_accessor_add_attribute(elementAccessor,attribute);
break;
}
@ -1322,6 +1328,13 @@ static GRIB_INLINE void reset_qualifiers(grib_accessor* significanceQualifierGro
significanceQualifierGroup[i]=0;
}
static void grib_convert_to_attribute(grib_accessor* a) {
if (a->h==NULL && a->parent!=NULL) {
a->h=a->parent->h;
a->parent=NULL;
}
}
static int create_keys(grib_accessor* a)
{
grib_accessor_bufr_data_array *self =(grib_accessor_bufr_data_array*)a;
@ -1339,7 +1352,7 @@ static int create_keys(grib_accessor* a)
long indexOfGroupNumber=0;
int depth;
int idx;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
int qualityPresent=0;
bitmap_s bitmap={0,};
int extraElement=0;
@ -1534,10 +1547,11 @@ static int create_keys(grib_accessor* a)
switch (descriptor->code) {
case 999999:
associatedFieldAccessor=elementAccessor;
grib_convert_to_attribute(associatedFieldAccessor);
if (associatedFieldSignificanceAccessor) {
grib_accessor* newAccessor=grib_accessor_clone(associatedFieldSignificanceAccessor,associatedFieldAccessor->parent,&err);
grib_accessor* newAccessor=grib_accessor_clone(associatedFieldSignificanceAccessor,section,&err);
if (err) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"unable to clone accessor '%s'\n",associatedFieldSignificanceAccessor->name);
grib_context_log(a->context,GRIB_LOG_ERROR,"unable to clone accessor '%s'\n",associatedFieldSignificanceAccessor->name);
return err;
}
grib_accessor_add_attribute(associatedFieldAccessor,newAccessor);
@ -1875,7 +1889,7 @@ static int value_count(grib_accessor* a,long* count)
int err=0,l;
long i,subsetNumber=0;
grib_accessor_bufr_data_array *self =(grib_accessor_bufr_data_array*)a;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
err=process_elements(a,PROCESS_DECODE);
if (err) return err;
@ -1900,7 +1914,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
size_t l=0,elementsInSubset;
long numberOfSubsets=0;
grib_accessor_bufr_data_array *self =(grib_accessor_bufr_data_array*)a;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
if (self->unpackMode == CODES_BUFR_NEW_DATA) proc_flag=PROCESS_NEW_DATA;

View File

@ -167,16 +167,19 @@ static grib_accessor* clone(grib_accessor* a,grib_section* s,int* err) {
creator.op = "bufr_data_element";
creator.name_space = "";
creator.set = 0;
creator.name="unknown";
if (strcmp(a->cclass->name,"bufr_data_element")) {
grib_context_log(a->parent->h->context,GRIB_LOG_FATAL,"wrong accessor type: '%s' should be '%s'",a->cclass->name,"bufr_data_element");
grib_context_log(a->context,GRIB_LOG_FATAL,"wrong accessor type: '%s' should be '%s'",a->cclass->name,"bufr_data_element");
}
*err=0;
creator.name=grib_context_strdup(a->parent->h->context,a->name);
clone = grib_accessor_factory(s, &creator, 0, NULL);
clone->name=grib_context_strdup(a->context,a->name);
elementAccessor=(grib_accessor_bufr_data_element*)clone;
self=(grib_accessor_bufr_data_element*)a;
clone->flags=a->flags;
clone->parent=NULL;
clone->h=s->h;
elementAccessor->index=self->index;
elementAccessor->type=self->type;
elementAccessor->numberOfSubsets=self->numberOfSubsets;
@ -190,6 +193,7 @@ static grib_accessor* clone(grib_accessor* a,grib_section* s,int* err) {
i=0;
while (a->attributes[i]) {
attribute=grib_accessor_clone(a->attributes[i],s,err);
/* attribute->parent=a->parent; */
grib_accessor_add_attribute(clone,attribute);
i++;
}
@ -272,7 +276,7 @@ static int unpack_string_array (grib_accessor* a, char** val, size_t *len)
int ret=0,i,idx;
long count=0;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
if (self->compressedData) {
idx=((int)self->numericValues->v[self->index]->v[0]/1000-1)/self->numberOfSubsets;
@ -296,7 +300,7 @@ static int pack_string_array(grib_accessor*a , const char** v, size_t *len){
int ret=0,i,idx;
char* s=NULL;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
if (self->compressedData) {
idx=((int)self->numericValues->v[self->index]->v[0]/1000-1)/self->numberOfSubsets;
@ -329,7 +333,7 @@ static int unpack_string (grib_accessor* a, char* val, size_t *len)
size_t dlen=1;
int ret=0,i,idx;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
if (self->type != BUFR_DESCRIPTOR_TYPE_STRING) {
unpack_double(a,&dval,&dlen);
@ -379,7 +383,7 @@ static int pack_string(grib_accessor* a, const char* val, size_t *len)
int ret=0,i,idx;
long count=0;
char* s=NULL;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
count=self->numberOfSubsets;
idx=((int)self->numericValues->v[self->index]->v[0]/1000-1)/self->numberOfSubsets;
@ -444,7 +448,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
int ret=0,i;
long count=1,n;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
if (self->compressedData) {
count=*len;
@ -453,11 +457,11 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
self->descriptors->v[self->elementsDescriptorsIndex->v[0]->v[self->index]]->shortName,count,self->numberOfSubsets);
return GRIB_ARRAY_TOO_SMALL;
}
grib_darray_delete(a->parent->h->context,self->numericValues->v[self->index]);
self->numericValues->v[self->index]=grib_darray_new(a->parent->h->context,count,1);
grib_darray_delete(a->context,self->numericValues->v[self->index]);
self->numericValues->v[self->index]=grib_darray_new(a->context,count,1);
for (i=0;i<count;i++)
grib_darray_push(a->parent->h->context,self->numericValues->v[self->index],val[i]);
grib_darray_push(a->context,self->numericValues->v[self->index],val[i]);
*len=count;
} else {
@ -473,7 +477,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
int ret=0,i;
long count=1;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
if (self->compressedData) {
count=*len;
@ -482,10 +486,10 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
self->descriptors->v[self->elementsDescriptorsIndex->v[0]->v[self->index]]->shortName,count,self->numberOfSubsets);
return GRIB_ARRAY_TOO_SMALL;
}
grib_darray_delete(a->parent->h->context,self->numericValues->v[self->index]);
grib_darray_delete(a->context,self->numericValues->v[self->index]);
for (i=0;i<count;i++) {
grib_darray_push(a->parent->h->context,self->numericValues->v[self->index], val[i] == GRIB_MISSING_LONG ? GRIB_MISSING_DOUBLE : val[i]);
grib_darray_push(a->context,self->numericValues->v[self->index], val[i] == GRIB_MISSING_LONG ? GRIB_MISSING_DOUBLE : val[i]);
}
*len=count;
} else {
@ -550,6 +554,7 @@ static void destroy(grib_context* ct, grib_accessor* a)
int i=0;
while (i<MAX_ACCESSOR_ATTRIBUTES && a->attributes[i]) {
grib_context_log(ct,GRIB_LOG_DEBUG,"deleting attribute %s->%s",a->name,a->attributes[i]->name);
/* printf("+++++ %s\n",a->attributes[i]->name); */
grib_accessor_delete(ct,a->attributes[i]);
a->attributes[i]=NULL;
i++;

View File

@ -219,7 +219,7 @@ static grib_trie* load_bufr_elements_table(grib_accessor* a, int* err) {
grib_trie* dictionary=NULL;
FILE* f=NULL;
grib_handle* h=a->parent->h;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
*err=GRIB_SUCCESS;
@ -324,7 +324,7 @@ static int bufr_get_from_table(grib_accessor* a,bufr_descriptor* v) {
table=load_bufr_elements_table(a,&ret);
if (ret) return ret;
c=a->parent->h->context;
c=a->context;
sprintf(code,"%06ld",v->code);
@ -368,7 +368,7 @@ bufr_descriptor* accessor_bufr_elements_table_get_descriptor(grib_accessor* a,in
if (!a) return NULL;
c=a->parent->h->context;
c=a->context;
v=(bufr_descriptor*)grib_context_malloc_clear(c,sizeof(bufr_descriptor));
if (!v) {

View File

@ -153,7 +153,7 @@ static int unpack_long (grib_accessor* a, long* val, size_t *len)
long* descriptors=0;
int err=0;
long F;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
err=grib_get_size(a->parent->h,self->expandedDescriptors,&size);
if (err) return err;

View File

@ -169,7 +169,7 @@ static grib_accessor* get_accessor(grib_accessor* a) {
static int unpack_string_array (grib_accessor* a, char** buffer, size_t *len)
{
grib_accessor* data=0;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
grib_vsarray* stringValues=NULL;
long l=0,n=0,tl;
size_t size,i,j;

View File

@ -173,7 +173,7 @@ static int unpack_long (grib_accessor* a, long* val, size_t *len)
long lenall=0;
size_t i;
long* v=0;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
descriptors=get_accessor(a);
if (!descriptors) return GRIB_NOT_FOUND;
@ -196,7 +196,7 @@ static int unpack_long (grib_accessor* a, long* val, size_t *len)
static int unpack_string_array (grib_accessor* a, char** buffer, size_t *len)
{
grib_accessor* descriptors=0;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
long l=0;
size_t size,i;
char buf[25]={0,};

View File

@ -177,7 +177,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
size_t size=0;
double* values=NULL;
grib_accessor_change_scanning_direction* self= (grib_accessor_change_scanning_direction*)a;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
grib_handle* h=a->parent->h;
if (*val==0) return 0;

View File

@ -164,8 +164,8 @@ static int grib_get_codeflag(grib_accessor* a, long code, char* codename)
grib_recompose_name(a->parent->h,NULL, self->tablename, fname,1);
if ((filename=grib_context_full_defs_path(a->parent->h->context,fname))==NULL) {
grib_context_log(a->parent->h->context,GRIB_LOG_WARNING,"Cannot open flag table %s",filename);
if ((filename=grib_context_full_defs_path(a->context,fname))==NULL) {
grib_context_log(a->context,GRIB_LOG_WARNING,"Cannot open flag table %s",filename);
strcpy(codename, "Cannot open flag table");
return GRIB_FILE_NOT_FOUND;
}
@ -174,7 +174,7 @@ static int grib_get_codeflag(grib_accessor* a, long code, char* codename)
if (!f)
{
grib_context_log(a->parent->h->context,(GRIB_LOG_WARNING)|(GRIB_LOG_PERROR),"Cannot open flag table %s",filename);
grib_context_log(a->context,(GRIB_LOG_WARNING)|(GRIB_LOG_PERROR),"Cannot open flag table %s",filename);
strcpy(codename, "Cannot open flag table");
return GRIB_FILE_NOT_FOUND;
}

View File

@ -178,7 +178,7 @@ static void init(grib_accessor* a, const long len, grib_arguments* params) {
if (a->flags & GRIB_ACCESSOR_FLAG_TRANSIENT) {
a->length = 0;
if (!a->vvalue)
a->vvalue = (grib_virtual_value*)grib_context_malloc_clear(a->parent->h->context,sizeof(grib_virtual_value));
a->vvalue = (grib_virtual_value*)grib_context_malloc_clear(a->context,sizeof(grib_virtual_value));
a->vvalue->type=grib_accessor_get_native_type(a);
a->vvalue->length=len;
if (act->default_value!=NULL) {
@ -205,7 +205,7 @@ static void init(grib_accessor* a, const long len, grib_arguments* params) {
len = sizeof(tmp);
p = grib_expression_evaluate_string(a->parent->h,expression,tmp,&len,&ret);
if (ret != GRIB_SUCCESS) {
grib_context_log(a->parent->h->context,GRIB_LOG_FATAL,
grib_context_log(a->context,GRIB_LOG_FATAL,
"unable to evaluate %s as string",a->name);
}
len = strlen(p)+1;
@ -645,7 +645,7 @@ static int pack_string(grib_accessor* a, const char* buffer, size_t *len)
len = sizeof(tmp);
p = grib_expression_evaluate_string(a->parent->h,expression,tmp,&len,&ret);
if (ret != GRIB_SUCCESS) {
grib_context_log(a->parent->h->context,GRIB_LOG_FATAL,
grib_context_log(a->context,GRIB_LOG_FATAL,
"unable to evaluate %s as string",a->name);
return ret;
}
@ -674,7 +674,7 @@ static int pack_expression(grib_accessor* a, grib_expression *e){
len = sizeof(tmp);
cval = grib_expression_evaluate_string(a->parent->h,e,tmp,&len,&ret);
if (ret!=GRIB_SUCCESS) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"grib_accessor_codetable.pack_expression: unable to evaluate string %s to be set in %s\n",grib_expression_get_name(e),a->name);
grib_context_log(a->context,GRIB_LOG_ERROR,"grib_accessor_codetable.pack_expression: unable to evaluate string %s to be set in %s\n",grib_expression_get_name(e),a->name);
return ret;
}
len = strlen(cval) + 1;
@ -715,7 +715,7 @@ static int unpack_long (grib_accessor* a, long* val, size_t *len)
if(*len < rlen)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, " wrong size (%ld) for %s it contains %d values ",*len, a->name , rlen);
grib_context_log(a->context, GRIB_LOG_ERROR, " wrong size (%ld) for %s it contains %d values ",*len, a->name , rlen);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -241,7 +241,7 @@ static int unpack_string (grib_accessor* a, char* val, size_t *len)
slen = strlen(p) +1;
if(*len < slen)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Variable unpack_string Wrong size for %s it is %d bytes big (len=%d)", a->name , slen ,*len);
grib_context_log(a->context, GRIB_LOG_ERROR, "Variable unpack_string Wrong size for %s it is %d bytes big (len=%d)", a->name , slen ,*len);
*len = slen;
return GRIB_BUFFER_TOO_SMALL;
}
@ -287,7 +287,7 @@ static int compare(grib_accessor* a,grib_accessor* b)
if (alen != blen) return GRIB_COUNT_MISMATCH;
aval=(char*)grib_context_malloc(a->parent->h->context,alen*sizeof(char));
aval=(char*)grib_context_malloc(a->context,alen*sizeof(char));
bval=(char*)grib_context_malloc(b->parent->h->context,blen*sizeof(char));
grib_unpack_string(a,aval,&alen);
@ -296,7 +296,7 @@ static int compare(grib_accessor* a,grib_accessor* b)
retval = GRIB_SUCCESS;
if (!aval || !bval || grib_inline_strcmp(aval,bval)) retval = GRIB_STRING_VALUE_MISMATCH;
grib_context_free(a->parent->h->context,aval);
grib_context_free(a->context,aval);
grib_context_free(b->parent->h->context,bval);
return retval;

View File

@ -139,7 +139,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)
{
*val = a->parent->h->context->handle_file_count;
*val = a->context->handle_file_count;
*len =1;
return 0;
}

View File

@ -208,7 +208,7 @@ static int unpack_long (grib_accessor* a, long* val, size_t *len)
if (grib_get_long(h,self->unusedBitsInBitmap,&unusedBitsInBitmap) != GRIB_SUCCESS) {
if (grib_get_long(h,self->numberOfDataPoints,&numberOfDataPoints) != GRIB_SUCCESS) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"unable to count missing values");
grib_context_log(a->context,GRIB_LOG_ERROR,"unable to count missing values");
return GRIB_INTERNAL_ERROR;
}
unusedBitsInBitmap=size*8-numberOfDataPoints;

View File

@ -141,7 +141,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)
{
*val = a->parent->h->context->handle_total_count;
*val = a->context->handle_total_count;
*len =1;
return 0;
}

View File

@ -533,9 +533,9 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
if ((abitmap=grib_find_accessor(a->parent->h,self->bitmap))!=NULL) {
bitmap_len=grib_byte_count(abitmap);
bitmap=(unsigned char*)grib_context_malloc_clear(a->parent->h->context,sizeof(char)*bitmap_len);
bitmap=(unsigned char*)grib_context_malloc_clear(a->context,sizeof(char)*bitmap_len);
err=grib_unpack_bytes(abitmap,bitmap,&bitmap_len);
if (err) {grib_context_free(a->parent->h->context,bitmap); return err;}
if (err) {grib_context_free(a->context,bitmap); return err;}
}
if(bits_per_value == 0)
@ -577,9 +577,9 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
if(snd_bitmap || matrix_values)
return GRIB_NOT_IMPLEMENTED;
sec_val = (unsigned long*)grib_context_malloc(a->parent->h->context,(n_vals)*sizeof(unsigned long));
grib_context_free(a->parent->h->context,sec_val);
sec_val = (unsigned long*)grib_context_malloc(a->parent->h->context,(n_vals)*sizeof(unsigned long));
sec_val = (unsigned long*)grib_context_malloc(a->context,(n_vals)*sizeof(unsigned long));
grib_context_free(a->context,sec_val);
sec_val = (unsigned long*)grib_context_malloc(a->context,(n_vals)*sizeof(unsigned long));
buf_width_of_group += a->offset;
buf_size_of_groups += offsetsection+(octet_start_group-1); /* -1 because of documented starting at 1(and not 0)*/
@ -603,14 +603,14 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
pointer_of_group_width = 8+(pointer_of_group_width-(pointer_of_group_width%8));
#if KEEP_OLD == 1
if(sd == NULL){
sd = grib_context_malloc_clear(a->parent->h->context,sizeof(second_order_packed));
sd = grib_context_malloc_clear(a->context,sizeof(second_order_packed));
sd->packed_byte_count = 0;
sd->nbits_per_group_size = nbits_per_group_size;
sd->nbits_per_widths = nbits_per_width;
sd->size_of_group_array = p1;
sd->array_of_group_size = grib_context_malloc_clear(a->parent->h->context,sizeof(unsigned long)*sd->size_of_group_array);
sd->array_of_group_width = grib_context_malloc_clear(a->parent->h->context,sizeof(unsigned long)*sd->size_of_group_array);
sd->array_of_group_refs = grib_context_malloc_clear(a->parent->h->context,sizeof( long)*sd->size_of_group_array);
sd->array_of_group_size = grib_context_malloc_clear(a->context,sizeof(unsigned long)*sd->size_of_group_array);
sd->array_of_group_width = grib_context_malloc_clear(a->context,sizeof(unsigned long)*sd->size_of_group_array);
sd->array_of_group_refs = grib_context_malloc_clear(a->context,sizeof( long)*sd->size_of_group_array);
}
#endif
for(i=0;i < p1;i++){
@ -639,7 +639,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
printf("readvalue [%d] %ld %ld bias %ld <<\n", i,sec_val[i],binary_scale_factor,bias );*/
if(snd_ordr_wdiff)
de_spatial_difference(a->parent->h->context,sec_val, n_vals, n_sp_diff, bias);
de_spatial_difference(a->context,sec_val, n_vals, n_sp_diff, bias);
if(boustrophedonic)
reverse_rows(sec_val,n_vals,nap,bitmap,bitmap_len);
@ -662,8 +662,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
min *= d;
max *= d;
grib_context_free(a->parent->h->context,sec_val);
if (bitmap!=NULL) grib_context_free(a->parent->h->context,bitmap);
grib_context_free(a->context,sec_val);
if (bitmap!=NULL) grib_context_free(a->context,bitmap);
return err;
}
@ -757,9 +757,9 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
if ((abitmap=grib_find_accessor(a->parent->h,self->bitmap))!=NULL) {
bitmap_len=grib_byte_count(abitmap);
bitmap=(unsigned char*)grib_context_malloc_clear(a->parent->h->context,sizeof(char)*bitmap_len);
bitmap=(unsigned char*)grib_context_malloc_clear(a->context,sizeof(char)*bitmap_len);
err=grib_unpack_bytes(abitmap,bitmap,&bitmap_len);
if (err) {grib_context_free(a->parent->h->context,bitmap); return err;}
if (err) {grib_context_free(a->context,bitmap); return err;}
}
two_ordr_spd = 1;
@ -771,7 +771,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
n_sp_diff = two_ordr_spd*2+plus1_spd;
/* calculation of integer array */
sec_val = (unsigned long*)grib_context_malloc(a->parent->h->context,(n_vals)*sizeof(long));
sec_val = (unsigned long*)grib_context_malloc(a->context,(n_vals)*sizeof(long));
d = grib_power(decimal_scale_factor,10) ;
max = val[0];
min = max;
@ -786,7 +786,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
bit_per_val_rectified_for_gribex = bits_per_value+8-bits_per_value%8;
if (grib_get_nearest_smaller_value(a->parent->h,self->reference_value,min,&reference_value)
!=GRIB_SUCCESS) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"unable to find nearest_smaller_value of %g for %s",min,self->reference_value);
exit(GRIB_INTERNAL_ERROR);
}
@ -806,8 +806,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
if(snd_ordr_wdiff)
if((err = spatial_difference(a->parent->h->context,sec_val, n_vals, n_sp_diff, &bias))){
grib_context_free(a->parent->h->context,sec_val);
if((err = spatial_difference(a->context,sec_val, n_vals, n_sp_diff, &bias))){
grib_context_free(a->context,sec_val);
return err;
}
@ -822,7 +822,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
#if KEEP_OLD == 1
#else
sd = grib_get_second_order_groups(a->parent->h->context, group_val, nv);
sd = grib_get_second_order_groups(a->context, group_val, nv);
#endif
bitp = 0;
@ -847,7 +847,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
if((a->offset+buff_len)%2) buff_len++;
buf = NULL;
buf = (unsigned char*)grib_context_malloc_clear(a->parent->h->context,buff_len);
buf = (unsigned char*)grib_context_malloc_clear(a->context,buff_len);
buf_width_of_group = buf;
buf_size_of_groups = buf+octet_start_group;
@ -935,13 +935,13 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
#else
grib_free_second_order_groups(a->parent->h->context,sd);
grib_free_second_order_groups(a->context,sd);
#endif
;
grib_context_free(a->parent->h->context,buf);
grib_context_free(a->parent->h->context,sec_val);
if (bitmap!=NULL) grib_context_free(a->parent->h->context,bitmap);
grib_context_free(a->context,buf);
grib_context_free(a->context,sec_val);
if (bitmap!=NULL) grib_context_free(a->context,bitmap);
return GRIB_SUCCESS;
}

View File

@ -220,17 +220,17 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
!= GRIB_SUCCESS)
return err;
coded_vals = (double*)grib_context_malloc(a->parent->h->context,coded_n_vals*sizeof(double));
coded_vals = (double*)grib_context_malloc(a->context,coded_n_vals*sizeof(double));
if(coded_vals == NULL) return GRIB_OUT_OF_MEMORY;
if((err = grib_get_double_array_internal(a->parent->h,self->coded_values,coded_vals,&coded_n_vals))
!= GRIB_SUCCESS)
{
grib_context_free(a->parent->h->context,coded_vals);
grib_context_free(a->context,coded_vals);
return err;
}
grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG,
grib_context_log(a->context, GRIB_LOG_DEBUG,
"grib_accessor_class_data_apply_bitmap: unpack_double : creating %s, %d values",
a->name, n_vals);
@ -244,8 +244,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
val[i] = coded_vals[j++];
if(j>coded_n_vals)
{
grib_context_free(a->parent->h->context,coded_vals);
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR,
grib_context_free(a->context,coded_vals);
grib_context_log(a->context, GRIB_LOG_ERROR,
"grib_accessor_class_data_apply_bitmap [%s]:"
" unpack_double : number of coded values does not match bitmap %ld %ld",
a->name,coded_n_vals,n_vals);
@ -257,7 +257,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
*len = n_vals;
grib_context_free(a->parent->h->context,coded_vals);
grib_context_free(a->context,coded_vals);
return err;
}
@ -286,7 +286,7 @@ static int unpack_double_element(grib_accessor* a, size_t idx,double* val)
if (*val == 0) {*val=missing_value;return GRIB_SUCCESS;}
bvals = (double*)grib_context_malloc(a->parent->h->context,n_vals*sizeof(double));
bvals = (double*)grib_context_malloc(a->context,n_vals*sizeof(double));
if(bvals == NULL) return GRIB_OUT_OF_MEMORY;
if((err = grib_get_double_array_internal(a->parent->h,self->bitmap,bvals,&n_vals)) != GRIB_SUCCESS)
@ -295,7 +295,7 @@ static int unpack_double_element(grib_accessor* a, size_t idx,double* val)
cidx=0;
for (i=0;i<idx;i++) {cidx+=bvals[i];}
grib_context_free(a->parent->h->context,bvals);
grib_context_free(a->context,bvals);
return grib_get_double_element_internal(a->parent->h,self->coded_values,cidx,val);
}
@ -334,7 +334,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
return err;
}
coded_vals = (double*)grib_context_malloc_clear(a->parent->h->context,coded_n_vals*sizeof(double));
coded_vals = (double*)grib_context_malloc_clear(a->context,coded_n_vals*sizeof(double));
if(!coded_vals) return GRIB_OUT_OF_MEMORY;
for(i=0; i<*len ; i++)
@ -352,7 +352,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
err=grib_set_long_internal(a->parent->h,self->binary_scale_factor,0);
}
grib_context_free(a->parent->h->context,coded_vals);
grib_context_free(a->context,coded_vals);
return err;
}

View File

@ -197,12 +197,12 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
if (valuesSize==0) return 0;
if (valuesSize!=numberOfPoints) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"boustrophedonic ordering error: ( %s=%ld ) != (sizeOf(%s)=%ld)",
grib_context_log(a->context,GRIB_LOG_ERROR,"boustrophedonic ordering error: ( %s=%ld ) != (sizeOf(%s)=%ld)",
self->numberOfPoints,numberOfPoints,self->values,(long)valuesSize);
return GRIB_DECODING_ERROR;
}
values=(double*)grib_context_malloc_clear(a->parent->h->context,sizeof(double)*numberOfPoints);
values=(double*)grib_context_malloc_clear(a->context,sizeof(double)*numberOfPoints);
ret=grib_get_double_array_internal(a->parent->h,self->values,values,&valuesSize);
if (ret) return ret;
@ -217,7 +217,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
if (grib_get_size(a->parent->h,self->pl,&plSize) == GRIB_SUCCESS) {
Assert(plSize==numberOfRows);
pl=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*plSize);
pl=(long*)grib_context_malloc_clear(a->context,sizeof(long)*plSize);
ret=grib_get_long_array_internal(a->parent->h,self->pl,pl,&plSize);
if (ret) return ret;
@ -231,7 +231,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
}
}
grib_context_free(a->parent->h->context,pl);
grib_context_free(a->context,pl);
} else {
@ -247,7 +247,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
}
grib_context_free(a->parent->h->context,values);
grib_context_free(a->context,values);
return GRIB_SUCCESS;
}
@ -280,7 +280,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
valuesSize=numberOfPoints;
values=(double*)grib_context_malloc_clear(a->parent->h->context,sizeof(double)*numberOfPoints);
values=(double*)grib_context_malloc_clear(a->context,sizeof(double)*numberOfPoints);
pvalues=values;
pval=(double*)val;
@ -293,7 +293,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
if (grib_get_size(a->parent->h,self->pl,&plSize) == GRIB_SUCCESS) {
Assert(plSize==numberOfRows);
pl=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*plSize);
pl=(long*)grib_context_malloc_clear(a->context,sizeof(long)*plSize);
ret=grib_get_long_array_internal(a->parent->h,self->pl,pl,&plSize);
if (ret) return ret;
@ -307,7 +307,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
}
}
grib_context_free(a->parent->h->context,pl);
grib_context_free(a->context,pl);
} else {
@ -325,7 +325,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
ret=grib_set_double_array_internal(a->parent->h,self->values,values,valuesSize);
if (ret) return ret;
grib_context_free(a->parent->h->context,values);
grib_context_free(a->context,values);
return ret;
}

View File

@ -230,17 +230,17 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
!= GRIB_SUCCESS)
return err;
coded_vals = (double*)grib_context_malloc(a->parent->h->context,coded_n_vals*sizeof(double));
coded_vals = (double*)grib_context_malloc(a->context,coded_n_vals*sizeof(double));
if(coded_vals == NULL) return GRIB_OUT_OF_MEMORY;
if((err = grib_get_double_array_internal(a->parent->h,self->coded_values,coded_vals,&coded_n_vals))
!= GRIB_SUCCESS)
{
grib_context_free(a->parent->h->context,coded_vals);
grib_context_free(a->context,coded_vals);
return err;
}
grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG,
grib_context_log(a->context, GRIB_LOG_DEBUG,
"grib_accessor_class_data_apply_boustrophedonic_bitmap: unpack_double : creating %s, %d values",
a->name, n_vals);
@ -276,8 +276,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
val[i] = coded_vals[j++];
if(j>coded_n_vals)
{
grib_context_free(a->parent->h->context,coded_vals);
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR,
grib_context_free(a->context,coded_vals);
grib_context_log(a->context, GRIB_LOG_ERROR,
"grib_accessor_class_data_apply_boustrophedonic_bitmap [%s]:"
" unpack_double : number of coded values does not match bitmap %ld %ld",
a->name,coded_n_vals,n_vals);
@ -289,7 +289,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
*len = n_vals;
grib_context_free(a->parent->h->context,coded_vals);
grib_context_free(a->context,coded_vals);
return err;
}
@ -318,7 +318,7 @@ static int unpack_double_element(grib_accessor* a, size_t idx,double* val)
if (*val == 0) {*val=missing_value;return GRIB_SUCCESS;}
bvals = (double*)grib_context_malloc(a->parent->h->context,n_vals*sizeof(double));
bvals = (double*)grib_context_malloc(a->context,n_vals*sizeof(double));
if(bvals == NULL) return GRIB_OUT_OF_MEMORY;
if((err = grib_get_double_array_internal(a->parent->h,self->bitmap,bvals,&n_vals)) != GRIB_SUCCESS)
@ -327,7 +327,7 @@ static int unpack_double_element(grib_accessor* a, size_t idx,double* val)
cidx=0;
for (i=0;i<idx;i++) {cidx+=bvals[i];}
grib_context_free(a->parent->h->context,bvals);
grib_context_free(a->context,bvals);
return grib_get_double_element_internal(a->parent->h,self->coded_values,cidx,val);
}
@ -368,7 +368,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
Assert(numberOfPoints == bmaplen);
/* Create a copy of the incoming 'val' array because we're going to change it */
values = (double*)grib_context_malloc_clear(a->parent->h->context, sizeof(double)*numberOfPoints);
values = (double*)grib_context_malloc_clear(a->context, sizeof(double)*numberOfPoints);
if (!values) return GRIB_OUT_OF_MEMORY;
for(i=0; i<numberOfPoints; ++i) {
values[i] = val[i];
@ -395,7 +395,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
if((err = grib_set_double_array_internal(a->parent->h,self->bitmap,values,bmaplen)) != GRIB_SUCCESS)
return err;
grib_context_free(a->parent->h->context,values);
grib_context_free(a->context,values);
coded_n_vals = *len;
@ -404,7 +404,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
return err;
}
coded_vals = (double*)grib_context_malloc_clear(a->parent->h->context,coded_n_vals*sizeof(double));
coded_vals = (double*)grib_context_malloc_clear(a->context,coded_n_vals*sizeof(double));
if(!coded_vals) return GRIB_OUT_OF_MEMORY;
for(i=0; i<*len ; i++)
@ -424,7 +424,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
err=grib_set_long_internal(a->parent->h,self->binary_scale_factor,0);
}
grib_context_free(a->parent->h->context,coded_vals);
grib_context_free(a->context,coded_vals);
return err;
}

View File

@ -182,7 +182,7 @@ static int value_count(grib_accessor* a,long* number_of_points)
*number_of_points=0;
if((ret = grib_get_long(a->parent->h,self->number_of_points,number_of_points))
!= GRIB_SUCCESS) {
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR,
grib_context_log(a->context, GRIB_LOG_ERROR,
"grib_accessor_data_apply_gdsnotpresent: value_count: unable to get number of points");
}
@ -231,7 +231,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
}
if(number_of_values > 0){
coded_vals = (double*)grib_context_malloc(a->parent->h->context,number_of_values*sizeof(double));
coded_vals = (double*)grib_context_malloc(a->context,number_of_values*sizeof(double));
if(coded_vals == NULL)
return GRIB_OUT_OF_MEMORY;
@ -240,16 +240,16 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
size=number_of_values;
if((err=grib_get_double_array_internal(a->parent->h,self->coded_values,coded_vals,&size))
!= GRIB_SUCCESS) {
grib_context_free(a->parent->h->context,coded_vals);
grib_context_free(a->context,coded_vals);
return err;
}
if (number_of_values!=size) {
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR,
grib_context_log(a->context, GRIB_LOG_ERROR,
"grib_accessor_data_apply_gdsnotpresent : wrong numberOfValues %ld != %ld",
number_of_values,size);
}
grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG,
grib_context_log(a->context, GRIB_LOG_DEBUG,
"grib_accessor_data_apply_gdsnotpresent : unpack_double : creating %s, %d values",
a->name, number_of_points);
@ -264,7 +264,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
*len = number_of_points;
grib_context_free(a->parent->h->context,coded_vals);
grib_context_free(a->context,coded_vals);
return err;
}
@ -280,14 +280,14 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
ret=grib_set_long(a->parent->h,self->bitmap_present,bitmap_present);
if(ret) {
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR,
grib_context_log(a->context, GRIB_LOG_ERROR,
"Accessor %s cannont pack value for %s error %d \n", a->name, self->bitmap_present, ret);
return ret;
}
#if 0
if(!grib_find_accessor(a->parent->h,self->bitmap)){
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR,
grib_context_log(a->context, GRIB_LOG_ERROR,
"Accessor %s cannont access bitmap \n", a->name, self->bitmap_present, ret);
return ret;
}
@ -296,7 +296,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
ret = grib_set_double_array_internal(a->parent->h,self->coded_values,val,*len);
if(ret) {
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR,
grib_context_log(a->context, GRIB_LOG_ERROR,
"Accessor %s cannont pack value for %s error %d \n", a->name, self->coded_values, ret);
return ret;
}

View File

@ -276,7 +276,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
bits8 = ((bits_per_value + 7)/8)*8;
size = n_vals * (bits_per_value + 7)/8;
decoded = grib_context_buffer_malloc_clear(a->parent->h->context,size);
decoded = grib_context_buffer_malloc_clear(a->context,size);
if(!decoded) {
err = GRIB_OUT_OF_MEMORY;
goto cleanup;
@ -305,7 +305,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
cleanup:
grib_context_buffer_free(a->parent->h->context,decoded);
grib_context_buffer_free(a->context,decoded);
return err;
}
@ -422,7 +422,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
if (grib_get_nearest_smaller_value(a->parent->h,self->reference_value,min,&reference_value)
!=GRIB_SUCCESS) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"unable to find nearest_smaller_value of %g for %s",min,self->reference_value);
exit(GRIB_INTERNAL_ERROR);
}
@ -437,7 +437,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
divisor = grib_power(-binary_scale_factor,2);
bits8 = (bits_per_value+7)/8*8;
encoded = grib_context_buffer_malloc_clear(a->parent->h->context,bits8/8*n_vals);
encoded = grib_context_buffer_malloc_clear(a->context,bits8/8*n_vals);
if(!encoded) {
err = GRIB_OUT_OF_MEMORY;
@ -459,11 +459,11 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
}
/* buflen = n_vals*(bits_per_value/8);*/
grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG,
grib_context_log(a->context, GRIB_LOG_DEBUG,
"grib_accessor_data_ccsds_packing : pack_double : packing %s, %d values", a->name, n_vals);
buflen += 10240;
buf = grib_context_buffer_malloc_clear(a->parent->h->context,buflen);
buf = grib_context_buffer_malloc_clear(a->context,buflen);
if(!buf) {
err = GRIB_OUT_OF_MEMORY;
@ -526,8 +526,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
grib_buffer_replace(a, buf, buflen ,1,1);
cleanup:
grib_context_buffer_free(a->parent->h->context,buf);
grib_context_buffer_free(a->parent->h->context,encoded);
grib_context_buffer_free(a->context,buf);
grib_context_buffer_free(a->context,encoded);
if(err == GRIB_SUCCESS)
err = grib_set_long_internal(a->parent->h,self->number_of_values, *len);
@ -541,14 +541,14 @@ cleanup:
static int unpack_double(grib_accessor* a, double* val, size_t *len)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR,
grib_context_log(a->context, GRIB_LOG_ERROR,
"grib_accessor_data_ccsds_packing: ccsds support not enabled.");
return GRIB_NOT_IMPLEMENTED;
}
static int pack_double(grib_accessor* a, const double* val, size_t *len)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR,
grib_context_log(a->context, GRIB_LOG_ERROR,
"grib_accessor_data_ccsds_packing: ccsds support not enabled.");
return GRIB_NOT_IMPLEMENTED;
}

View File

@ -210,7 +210,7 @@ static int value_count(grib_accessor* a,long* count)
return ret;
if (pen_j != pen_k || pen_j!=pen_m ) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"pen_j=%ld, pen_k=%ld, pen_m=%ld\n",pen_j,pen_k,pen_m);
grib_context_log(a->context,GRIB_LOG_ERROR,"pen_j=%ld, pen_k=%ld, pen_m=%ld\n",pen_j,pen_k,pen_m);
Assert ((pen_j == pen_k) && (pen_j == pen_m));
}
*count=(pen_j+1)*(pen_j+2);
@ -346,7 +346,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
if (pen_j == sub_j) {
n_vals = (pen_j+1)*(pen_j+2);
d = grib_power(-decimal_scale_factor,10) ;
grib_ieee_decode_array(a->parent->h->context,buf,n_vals,bytes,val);
grib_ieee_decode_array(a->context,buf,n_vals,bytes,val);
if (d) {
for (i=0;i<n_vals;i++) val[i]*=d;
}
@ -360,7 +360,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
s = grib_power(binary_scale_factor,2);
d = grib_power(-decimal_scale_factor,10) ;
scals = (double*)grib_context_malloc(a->parent->h->context,maxv*sizeof(double));
scals = (double*)grib_context_malloc(a->context,maxv*sizeof(double));
Assert(scals);
scals[0] = 0;
@ -369,7 +369,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
if(operat != 0)
scals[i] = (1.0/operat);
else{
grib_context_log(a->parent->h->context,GRIB_LOG_WARNING,
grib_context_log(a->context,GRIB_LOG_WARNING,
"COMPLEX_PACKING : problem with operator div by zero at index %d of %d \n",
i , maxv);
scals[i] = 0;
@ -436,7 +436,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
val[i++] *= d;
}
grib_context_free(a->parent->h->context,scals);
grib_context_free(a->context,scals);
return ret;
@ -666,29 +666,29 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len) {
d = grib_power(decimal_scale_factor,10) ;
if(*len != n_vals){
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"COMPLEX_PACKING : wrong number of values, expected %d - got %d",n_vals,*len);
grib_context_log(a->context,GRIB_LOG_ERROR,"COMPLEX_PACKING : wrong number of values, expected %d - got %d",n_vals,*len);
return GRIB_INTERNAL_ERROR;
}
if (pen_j == sub_j) {
double* values;
if (d) {
values=(double*)grib_context_malloc_clear(a->parent->h->context,sizeof(double)*n_vals);
values=(double*)grib_context_malloc_clear(a->context,sizeof(double)*n_vals);
for (i=0;i<n_vals;i++) values[i]=val[i]*d;
} else {
values=(double*)val;
}
buflen=n_vals*bytes;
buf = (unsigned char*)grib_context_malloc_clear(a->parent->h->context,buflen);
grib_ieee_encode_array(a->parent->h->context,values,n_vals,bytes,buf);
if (d) grib_context_free(a->parent->h->context,values);
buf = (unsigned char*)grib_context_malloc_clear(a->context,buflen);
grib_ieee_encode_array(a->context,values,n_vals,bytes,buf);
if (d) grib_context_free(a->context,values);
grib_buffer_replace(a, buf, buflen,1,1);
grib_context_free(a->parent->h->context,buf);
grib_context_free(a->context,buf);
return 0;
}
if(!laplacianOperatorIsSet) {
laplacianOperator = calculate_pfactor(a->parent->h->context,val,pen_j,sub_j);
laplacianOperator = calculate_pfactor(a->context,val,pen_j,sub_j);
if((ret = grib_set_double_internal(a->parent->h,self->laplacianOperator,laplacianOperator))
!= GRIB_SUCCESS) return ret;
grib_get_double_internal(a->parent->h,self->laplacianOperator,&laplacianOperator);
@ -703,7 +703,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len) {
buflen = hsize+lsize;
buf = (unsigned char*)grib_context_malloc(a->parent->h->context,buflen);
buf = (unsigned char*)grib_context_malloc(a->context,buflen);
hres = buf;
lres = buf+hsize;
@ -712,7 +712,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len) {
lpos = 0;
hpos = 0;
scals = (double*) grib_context_malloc(a->parent->h->context,maxv*sizeof(double));
scals = (double*) grib_context_malloc(a->context,maxv*sizeof(double));
Assert(scals);
scals[0] =0;
@ -766,7 +766,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len) {
if (grib_get_nearest_smaller_value(a->parent->h,self->reference_value,min,&reference_value)
!=GRIB_SUCCESS) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"unable to find nearest_smaller_value of %g for %s",min,self->reference_value);
exit(GRIB_INTERNAL_ERROR);
}
@ -826,13 +826,13 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len) {
{
current_val = (((((val[i++]*d) * scals[lup])-reference_value)*s)+0.5);
if(current_val < 0)
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"COMPLEX_PACKING : negative coput before packing (%g)", current_val);
grib_encode_unsigned_longb(lres, current_val, &lpos, bits_per_value);
current_val = (((((val[i++]*d) * scals[lup])-reference_value)*s)+0.5);
if(current_val < 0)
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"COMPLEX_PACKING : negative coput before packing (%g)", current_val);
grib_encode_unsigned_longb(lres, current_val, &lpos, bits_per_value);
lup++;
@ -842,13 +842,13 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len) {
{
current_val = (((((val[i++]*d) * scals[lup])-reference_value)*s)+0.5);
if(current_val < 0)
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"COMPLEX_PACKING : negative coput before packing (%g)", current_val);
grib_encode_unsigned_long(lres, current_val, &lpos, bits_per_value);
current_val = (((((val[i++]*d) * scals[lup])-reference_value)*s)+0.5);
if(current_val < 0)
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"COMPLEX_PACKING : negative coput before packing (%g)", current_val);
grib_encode_unsigned_long(lres, current_val, &lpos, bits_per_value);
lup++;
@ -863,10 +863,10 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len) {
if(((hpos/8) != hsize) &&((lpos/8) != lsize))
{
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"COMPLEX_PACKING : Mismatch in packing between high resolution and low resolution part");
grib_context_free(a->parent->h->context,buf);
grib_context_free(a->parent->h->context,scals);
grib_context_free(a->context,buf);
grib_context_free(a->context,scals);
return GRIB_INTERNAL_ERROR;
}
@ -885,8 +885,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len) {
return ret;
grib_buffer_replace(a, buf, buflen,1,1);
grib_context_free(a->parent->h->context,buf);
grib_context_free(a->parent->h->context,scals);
grib_context_free(a->context,buf);
grib_context_free(a->context,scals);
return ret;

View File

@ -220,18 +220,18 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
buflen = (1+((bits_per_value*n_vals)/8))*sizeof(unsigned char);
buf = (unsigned char*)grib_context_malloc_clear(a->parent->h->context,buflen);
buf = (unsigned char*)grib_context_malloc_clear(a->context,buflen);
if (!buf) return GRIB_OUT_OF_MEMORY;
half_byte = (buflen*8)-((*len)*bits_per_value);
if((err = grib_set_long_internal(a->parent->h,self->half_byte, half_byte)) != GRIB_SUCCESS){
grib_context_free(a->parent->h->context,buf);
grib_context_free(a->context,buf);
return err;
}
grib_buffer_replace(a, buf, buflen,1,1);
grib_context_free(a->parent->h->context,buf);
grib_context_free(a->context,buf);
return GRIB_SUCCESS;
@ -245,7 +245,7 @@ static int value_count(grib_accessor* a,long* numberOfPoints)
if((err = grib_get_long_internal(a->parent->h,self->numberOfPoints, numberOfPoints))
!= GRIB_SUCCESS) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"unable to get count of %s (%s)",a->name,grib_get_error_message(err));
grib_context_log(a->context,GRIB_LOG_ERROR,"unable to get count of %s (%s)",a->name,grib_get_error_message(err));
}
return err;

View File

@ -192,7 +192,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
long half_byte= 0;
long bits_per_value =0;
size_t buflen =0;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
grib_handle* h=a->parent->h;
char* ieee_packing_s=NULL;
char* packingType_s=NULL;
@ -253,7 +253,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
buflen = 32*(sub_k+1)*(sub_k+2)+(*len-(sub_k+1)*(sub_k+2))*bits_per_value+18*8;
half_byte = seclen*8-buflen;
if (a->parent->h->context->debug==-1) {
if (a->context->debug==-1) {
printf("ECCODES DEBUG: half_byte=%ld\n",half_byte);
}

View File

@ -271,15 +271,15 @@ static int unpack_double(grib_accessor* a, double* values, size_t *len)
if((ret=grib_get_long_internal(a->parent->h,self->groupWidth, &groupWidth)) != GRIB_SUCCESS)
return ret;
secondaryBitmap=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*numberOfSecondOrderPackedValues);
secondaryBitmap=(long*)grib_context_malloc_clear(a->context,sizeof(long)*numberOfSecondOrderPackedValues);
grib_decode_long_array(buf,&pos,1,numberOfSecondOrderPackedValues,secondaryBitmap);
pos = 8 * ( (pos + 7 ) / 8);
firstOrderValues=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*numberOfGroups);
firstOrderValues=(long*)grib_context_malloc_clear(a->context,sizeof(long)*numberOfGroups);
grib_decode_long_array(buf,&pos,widthOfFirstOrderValues,numberOfGroups,firstOrderValues);
pos = 8 * ( (pos + 7 ) / 8);
X=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*numberOfSecondOrderPackedValues);
X=(long*)grib_context_malloc_clear(a->context,sizeof(long)*numberOfSecondOrderPackedValues);
if (groupWidth>0) {
grib_decode_long_array(buf,&pos,groupWidth,numberOfSecondOrderPackedValues,X);
@ -315,16 +315,16 @@ static int unpack_double(grib_accessor* a, double* values, size_t *len)
}
*len=numberOfSecondOrderPackedValues;
grib_context_free(a->parent->h->context,secondaryBitmap);
grib_context_free(a->parent->h->context,firstOrderValues);
grib_context_free(a->parent->h->context,X);
grib_context_free(a->context,secondaryBitmap);
grib_context_free(a->context,firstOrderValues);
grib_context_free(a->context,X);
return ret;
}
static int pack_double(grib_accessor* a, const double* cval, size_t *len)
{
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"constant width packing not implemented");
grib_context_log(a->context,GRIB_LOG_ERROR,"constant width packing not implemented");
return GRIB_NOT_IMPLEMENTED;
}

View File

@ -277,14 +277,14 @@ static int value_count(grib_accessor* a,long* count)
if (err) return err;
if (numberOfGroups==0) return 0;
groupLengths=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*numberOfGroups);
groupLengths=(long*)grib_context_malloc_clear(a->context,sizeof(long)*numberOfGroups);
ngroups=numberOfGroups;
err=grib_get_long_array(a->parent->h,self->groupLengths,groupLengths,&ngroups);
if (err) return err;
for (i=0;i<numberOfGroups;i++) numberOfCodedValues+=groupLengths[i];
grib_context_free(a->parent->h->context,groupLengths);
grib_context_free(a->context,groupLengths);
err=grib_get_long(a->parent->h,self->orderOfSPD,&orderOfSPD);
@ -305,11 +305,11 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val)
if (err) return err;
if (idx >= size) return GRIB_INVALID_NEAREST;
values=(double*)grib_context_malloc_clear(a->parent->h->context,size*sizeof(double));
values=(double*)grib_context_malloc_clear(a->context,size*sizeof(double));
err=grib_get_double_array(a->parent->h,"codedValues",values,&size);
if (err) return err;
*val=values[idx];
grib_context_free(a->parent->h->context,values);
grib_context_free(a->context,values);
return err;
}
@ -360,15 +360,15 @@ static int unpack_double(grib_accessor* a, double* values, size_t *len)
return ret;
ngroups=numberOfGroups;
groupWidths=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*numberOfGroups);
groupWidths=(long*)grib_context_malloc_clear(a->context,sizeof(long)*numberOfGroups);
ret=grib_get_long_array(a->parent->h,self->groupWidths,groupWidths,&ngroups);
if(ret != GRIB_SUCCESS) return ret;
groupLengths=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*numberOfGroups);
groupLengths=(long*)grib_context_malloc_clear(a->context,sizeof(long)*numberOfGroups);
ret=grib_get_long_array(a->parent->h,self->groupLengths,groupLengths,&ngroups);
if(ret != GRIB_SUCCESS) return ret;
firstOrderValues=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*numberOfGroups);
firstOrderValues=(long*)grib_context_malloc_clear(a->context,sizeof(long)*numberOfGroups);
ret=grib_get_long_array(a->parent->h,self->firstOrderValues,firstOrderValues,&ngroups);
if(ret != GRIB_SUCCESS) return ret;
@ -387,13 +387,13 @@ static int unpack_double(grib_accessor* a, double* values, size_t *len)
if (orderOfSPD) {
size_t nSPD=orderOfSPD+1;
SPD=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*nSPD);
SPD=(long*)grib_context_malloc_clear(a->context,sizeof(long)*nSPD);
ret=grib_get_long_array(a->parent->h,self->SPD,SPD,&nSPD);
bias=SPD[orderOfSPD];
if(ret != GRIB_SUCCESS) return ret;
}
X=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*numberOfValues);
X=(long*)grib_context_malloc_clear(a->context,sizeof(long)*numberOfValues);
n=orderOfSPD;
for (i=0;i<numberOfGroups;i++) {
@ -462,11 +462,11 @@ static int unpack_double(grib_accessor* a, double* values, size_t *len)
if (self->values) {
if (numberOfValues!=self->size) {
grib_context_free(a->parent->h->context,self->values);
self->values=(double*)grib_context_malloc_clear(a->parent->h->context,sizeof(double)*numberOfValues);
grib_context_free(a->context,self->values);
self->values=(double*)grib_context_malloc_clear(a->context,sizeof(double)*numberOfValues);
}
} else {
self->values=(double*)grib_context_malloc_clear(a->parent->h->context,sizeof(double)*numberOfValues);
self->values=(double*)grib_context_malloc_clear(a->context,sizeof(double)*numberOfValues);
}
s = grib_power(binary_scale_factor,2);
@ -479,12 +479,12 @@ static int unpack_double(grib_accessor* a, double* values, size_t *len)
*len=numberOfValues;
self->size=numberOfValues;
grib_context_free(a->parent->h->context,X);
grib_context_free(a->parent->h->context,groupWidths);
grib_context_free(a->parent->h->context,groupLengths);
grib_context_free(a->parent->h->context,firstOrderValues);
grib_context_free(a->context,X);
grib_context_free(a->context,groupWidths);
grib_context_free(a->context,groupLengths);
grib_context_free(a->context,firstOrderValues);
if (orderOfSPD)
grib_context_free(a->parent->h->context,SPD);
grib_context_free(a->context,SPD);
return ret;
}
@ -665,7 +665,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
if (grib_get_nearest_smaller_value(a->parent->h,self->reference_value,min,&reference_value)
!=GRIB_SUCCESS) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"unable to find nearest_smaller_value of %g for %s",min,self->reference_value);
exit(GRIB_INTERNAL_ERROR);
}
@ -692,14 +692,14 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
return ret;
divisor = grib_power(-binary_scale_factor,2);
X=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*numberOfValues);
X=(long*)grib_context_malloc_clear(a->context,sizeof(long)*numberOfValues);
for(i=0;i< numberOfValues;i++){
X[i] = (((val[i]*decimal)-reference_value)*divisor)+0.5;
}
groupLengths=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*numberOfValues);
groupWidths=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*numberOfValues);
firstOrderValues=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*numberOfValues);
groupLengths=(long*)grib_context_malloc_clear(a->context,sizeof(long)*numberOfValues);
groupWidths=(long*)grib_context_malloc_clear(a->context,sizeof(long)*numberOfValues);
firstOrderValues=(long*)grib_context_malloc_clear(a->context,sizeof(long)*numberOfValues);
/* spatial differencing */
switch (orderOfSPD) {
@ -963,7 +963,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
Focus on groups which have been shrank as left groups of an A group taking
some of their elements.
*/
offsets=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*numberOfGroups);
offsets=(long*)grib_context_malloc_clear(a->context,sizeof(long)*numberOfGroups);
offsets[0]=orderOfSPD;
for (i=1;i<numberOfGroups;i++) offsets[i]=offsets[i-1]+groupLengths[i-1];
for (i=numberOfGroups-2;i>=0;i--) {
@ -1019,7 +1019,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
}
}
grib_context_free(a->parent->h->context,offsets);
grib_context_free(a->context,offsets);
}
maxWidth=groupWidths[0];
@ -1036,8 +1036,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
lengthOfSecondOrderValues+=groupLengths[i]*groupWidths[i];
}
if (!a->parent->h->context->no_big_group_split) {
grib_split_long_groups(a->parent->h->context,&numberOfGroups,&lengthOfSecondOrderValues,
if (!a->context->no_big_group_split) {
grib_split_long_groups(a->context,&numberOfGroups,&lengthOfSecondOrderValues,
groupLengths,&widthOfLengths,groupWidths,widthOfWidths,
firstOrderValues,widthOfFirstOrderValues);
}
@ -1137,7 +1137,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
if((ret = grib_set_long_internal(a->parent->h,self->half_byte, half_byte)) != GRIB_SUCCESS)
return ret;
buffer=(unsigned char*)grib_context_malloc_clear(a->parent->h->context,size);
buffer=(unsigned char*)grib_context_malloc_clear(a->context,size);
pos=0;
if (orderOfSPD) {
@ -1181,11 +1181,11 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
grib_buffer_replace(a, buffer, size,1,1);
grib_context_free(a->parent->h->context,buffer);
grib_context_free(a->parent->h->context,X);
grib_context_free(a->parent->h->context,groupLengths);
grib_context_free(a->parent->h->context,groupWidths);
grib_context_free(a->parent->h->context,firstOrderValues);
grib_context_free(a->context,buffer);
grib_context_free(a->context,X);
grib_context_free(a->context,groupLengths);
grib_context_free(a->context,groupWidths);
grib_context_free(a->context,firstOrderValues);
return ret;
}

View File

@ -257,21 +257,21 @@ static int unpack_double(grib_accessor* a, double* values, size_t *len)
&numberOfSecondOrderPackedValues)) != GRIB_SUCCESS)
return ret;
groupWidths=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*numberOfGroups);
groupWidths=(long*)grib_context_malloc_clear(a->context,sizeof(long)*numberOfGroups);
groupWidthsSize=numberOfGroups;
if((ret=grib_get_long_array_internal(a->parent->h,self->groupWidths, groupWidths,&groupWidthsSize)) != GRIB_SUCCESS)
return ret;
secondaryBitmap=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*(numberOfSecondOrderPackedValues+1));
secondaryBitmap=(long*)grib_context_malloc_clear(a->context,sizeof(long)*(numberOfSecondOrderPackedValues+1));
secondaryBitmap[numberOfSecondOrderPackedValues]=1;
grib_decode_long_array(buf,&pos,1,numberOfSecondOrderPackedValues,secondaryBitmap);
pos = 8 * ( (pos + 7 ) / 8);
firstOrderValues=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*numberOfGroups);
firstOrderValues=(long*)grib_context_malloc_clear(a->context,sizeof(long)*numberOfGroups);
grib_decode_long_array(buf,&pos,widthOfFirstOrderValues,numberOfGroups,firstOrderValues);
pos = 8 * ( (pos + 7 ) / 8);
X=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*numberOfSecondOrderPackedValues);
X=(long*)grib_context_malloc_clear(a->context,sizeof(long)*numberOfSecondOrderPackedValues);
n=0;
i=-1;
@ -304,10 +304,10 @@ static int unpack_double(grib_accessor* a, double* values, size_t *len)
}
*len=numberOfSecondOrderPackedValues;
grib_context_free(a->parent->h->context,secondaryBitmap);
grib_context_free(a->parent->h->context,firstOrderValues);
grib_context_free(a->parent->h->context,X);
grib_context_free(a->parent->h->context,groupWidths);
grib_context_free(a->context,secondaryBitmap);
grib_context_free(a->context,firstOrderValues);
grib_context_free(a->context,X);
grib_context_free(a->context,groupWidths);
return ret;
}

View File

@ -215,7 +215,7 @@ static int value_count(grib_accessor* a,long* count)
size_t plSize=0;
long* pl=0;
int ret=0;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
if (self->bitmap) bitmapPresent=1;
if((ret=grib_get_long_internal(a->parent->h,self->jPointsAreConsecutive,&jPointsAreConsecutive)) != GRIB_SUCCESS)
@ -233,7 +233,7 @@ static int value_count(grib_accessor* a,long* count)
plSize=0;
ret=grib_get_size(a->parent->h,self->pl,&plSize);
if (ret==GRIB_SUCCESS) {
pl=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*plSize);
pl=(long*)grib_context_malloc_clear(a->context,sizeof(long)*plSize);
if((ret=grib_get_long_array(a->parent->h,self->pl,pl,&plSize)) != GRIB_SUCCESS)
return ret;
}
@ -250,12 +250,12 @@ static int value_count(grib_accessor* a,long* count)
} else {
numberOfPoints=Ni*Nj;
}
bitmap=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*numberOfPoints);
bitmap=(long*)grib_context_malloc_clear(a->context,sizeof(long)*numberOfPoints);
pbitmap=bitmap;
grib_get_long_array(a->parent->h,self->bitmap,bitmap,&numberOfPoints);
for (i=0;i<numberOfPoints;i++) n+=*(bitmap++);
grib_context_free(a->parent->h->context,pbitmap);
grib_context_free(a->context,pbitmap);
} else {
if (plSize) {
for (i=0;i<numberOfRows;i++) n+=pl[i];
@ -306,7 +306,7 @@ static int unpack_double(grib_accessor* a, double* values, size_t *len)
if (self->bitmap) bitmapPresent=1;
ret=grib_get_size(a->parent->h,self->pl,&plSize);
if (ret==GRIB_SUCCESS) {
pl=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*plSize);
pl=(long*)grib_context_malloc_clear(a->context,sizeof(long)*plSize);
if((ret=grib_get_long_array(a->parent->h,self->pl,pl,&plSize)) != GRIB_SUCCESS)
return ret;
}
@ -323,7 +323,7 @@ static int unpack_double(grib_accessor* a, double* values, size_t *len)
numberOfColumns=Ni;
}
numbersPerRow=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*numberOfRows);
numbersPerRow=(long*)grib_context_malloc_clear(a->context,sizeof(long)*numberOfRows);
if (bitmapPresent) {
long *bitmap,*pbitmap;
size_t numberOfPoints=Ni*Nj;
@ -332,7 +332,7 @@ static int unpack_double(grib_accessor* a, double* values, size_t *len)
numberOfPoints=0;
for (i=0;i<numberOfRows;i++) numberOfPoints+=pl[i];
}
bitmap=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*numberOfPoints);
bitmap=(long*)grib_context_malloc_clear(a->context,sizeof(long)*numberOfPoints);
pbitmap=bitmap;
grib_get_long_array(a->parent->h,self->bitmap,bitmap,&numberOfPoints);
if (plSize) {
@ -350,7 +350,7 @@ static int unpack_double(grib_accessor* a, double* values, size_t *len)
}
}
grib_context_free(a->parent->h->context,pbitmap);
grib_context_free(a->context,pbitmap);
} else {
if (plSize) {
for (i=0;i<numberOfRows;i++) numbersPerRow[i]=pl[i];
@ -376,19 +376,19 @@ static int unpack_double(grib_accessor* a, double* values, size_t *len)
&numberOfSecondOrderPackedValues)) != GRIB_SUCCESS)
return ret;
groupWidths=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*numberOfGroups);
groupWidths=(long*)grib_context_malloc_clear(a->context,sizeof(long)*numberOfGroups);
groupWidthsSize=numberOfGroups;
if((ret=grib_get_long_array_internal(a->parent->h,self->groupWidths, groupWidths,&groupWidthsSize)) != GRIB_SUCCESS)
return ret;
firstOrderValues=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*numberOfGroups);
firstOrderValues=(long*)grib_context_malloc_clear(a->context,sizeof(long)*numberOfGroups);
grib_decode_long_array(buf,&pos,widthOfFirstOrderValues,numberOfGroups,firstOrderValues);
pos = 8 * ( (pos + 7 ) / 8);
n=0;
for (i=0; i<numberOfGroups; i++) n+=numbersPerRow[i];
X=(long*)grib_context_malloc_clear(a->parent->h->context,sizeof(long)*n);
X=(long*)grib_context_malloc_clear(a->context,sizeof(long)*n);
n=0;
k=0;
for (i=0; i<numberOfGroups; i++) {
@ -412,10 +412,10 @@ static int unpack_double(grib_accessor* a, double* values, size_t *len)
for (i=0; i<n; i++) {
values[i] = (double) (((X[i]*s)+reference_value)*d);
}
grib_context_free(a->parent->h->context,firstOrderValues);
grib_context_free(a->parent->h->context,X);
grib_context_free(a->parent->h->context,groupWidths);
if (plSize) grib_context_free(a->parent->h->context,pl);
grib_context_free(a->context,firstOrderValues);
grib_context_free(a->context,X);
grib_context_free(a->context,groupWidths);
if (plSize) grib_context_free(a->context,pl);
return ret;
}

View File

@ -195,13 +195,13 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
}
primary_len = *len / expand_by;
primary_bitmap= (double*)grib_context_malloc_clear(a->parent->h->context,primary_len*sizeof(double));
primary_bitmap= (double*)grib_context_malloc_clear(a->context,primary_len*sizeof(double));
if(!primary_bitmap) return GRIB_OUT_OF_MEMORY;
secondary_len = *len ;
secondary_bitmap= (double*)grib_context_malloc_clear(a->parent->h->context,secondary_len*sizeof(double));
secondary_bitmap= (double*)grib_context_malloc_clear(a->context,secondary_len*sizeof(double));
if(!secondary_bitmap) {
grib_context_free(a->parent->h->context,primary_bitmap);
grib_context_free(a->context,primary_bitmap);
return GRIB_OUT_OF_MEMORY;
}
@ -238,8 +238,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
if(err == GRIB_SUCCESS)
err = grib_set_double_array_internal(a->parent->h,self->secondary_bitmap,secondary_bitmap,m);
grib_context_free(a->parent->h->context,primary_bitmap);
grib_context_free(a->parent->h->context,secondary_bitmap);
grib_context_free(a->context,primary_bitmap);
grib_context_free(a->context,secondary_bitmap);
if(err == GRIB_SUCCESS)
err = grib_set_long_internal(a->parent->h,self->number_of_ones,on);

View File

@ -171,7 +171,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
if((err = grib_get_double_array_internal(a->parent->h,self->coded_values,val,&coded_n_vals)) != GRIB_SUCCESS)
return err;
grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG,
grib_context_log(a->context, GRIB_LOG_DEBUG,
"grib_accessor_data_g1shsimple_packing_bitmap : unpack_double : creating %s, %d values",
a->name, n_vals);

View File

@ -199,7 +199,7 @@ static int pack_double(grib_accessor* a, const double* cval, size_t *len)
double divisor = 1;
int i;
long off = 0;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
grib_handle* h=a->parent->h;
char* ieee_packing_s=NULL;
char* packingType_s=NULL;
@ -277,12 +277,12 @@ static int pack_double(grib_accessor* a, const double* cval, size_t *len)
return GRIB_SUCCESS;
break;
case GRIB_INVALID_BPV:
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"unable to compute packing parameters\n");
grib_context_log(a->context,GRIB_LOG_ERROR,"unable to compute packing parameters\n");
return ret;
case GRIB_SUCCESS:
break;
default:
grib_context_log(a->parent->h->context,GRIB_LOG_FATAL,"unable to compute packing parameters\n");
grib_context_log(a->context,GRIB_LOG_FATAL,"unable to compute packing parameters\n");
return ret;
}
@ -320,7 +320,7 @@ static int pack_double(grib_accessor* a, const double* cval, size_t *len)
*/
}
half_byte = (buflen*8)-((*len)*bits_per_value);
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG,
grib_context_log(a->context,GRIB_LOG_DEBUG,
"HALF byte: buflen=%d bits_per_value=%ld len=%d half_byte=%ld\n",
buflen,bits_per_value,*len,half_byte);
@ -330,17 +330,17 @@ static int pack_double(grib_accessor* a, const double* cval, size_t *len)
!= GRIB_SUCCESS)
return ret;
buf = (unsigned char*)grib_context_buffer_malloc_clear(a->parent->h->context,buflen);
buf = (unsigned char*)grib_context_buffer_malloc_clear(a->context,buflen);
encoded = buf;
grib_encode_double_array(n_vals,val,bits_per_value,reference_value,decimal,divisor,encoded,&off);
grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG,
grib_context_log(a->context, GRIB_LOG_DEBUG,
"grib_accessor_data_g1simple_packing : pack_double : packing %s, %d values", a->name, n_vals);
grib_buffer_replace(a, buf, buflen,1,1);
grib_context_buffer_free(a->parent->h->context,buf);
grib_context_buffer_free(a->context,buf);
return GRIB_SUCCESS;
}

View File

@ -472,7 +472,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
fprintf(stdout," orderOfSpatialDifferencing = %d\n", orderOfSpatialDifferencing);
fprintf(stdout,"\n****************************************\n");
*/
sec_val = (unsigned long*)grib_context_malloc(a->parent->h->context,(n_vals)*sizeof(unsigned long));
sec_val = (unsigned long*)grib_context_malloc(a->context,(n_vals)*sizeof(unsigned long));
if (sec_val) memset(sec_val, 0, (n_vals)*sizeof(unsigned long)); /* See SUP-718 */
buf_ref = buf + a->offset ;
@ -526,7 +526,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
bias = grib_decode_signed_longb(buf_ref, &ref_p, numberOfOctetsExtraDescriptors*8);
de_spatial_difference (a->parent->h->context, sec_val, n_vals, orderOfSpatialDifferencing, bias);
de_spatial_difference (a->context, sec_val, n_vals, orderOfSpatialDifferencing, bias);
}
binary_s = grib_power(binary_scale_factor,2);
@ -535,7 +535,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
for(i=0;i < n_vals;i++)
val[i] = (double) ((((double)sec_val[i])*binary_s)+reference_value)*decimal_s;
grib_context_free(a->parent->h->context,sec_val);
grib_context_free(a->context,sec_val);
return err;
}
@ -622,7 +622,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
/* calculation of integer array */
sec_val = NULL;
sec_val = (unsigned long*)grib_context_malloc(a->parent->h->context,(n_vals)*sizeof(long));
sec_val = (unsigned long*)grib_context_malloc(a->context,(n_vals)*sizeof(long));
if(!sec_val) return GRIB_OUT_OF_MEMORY;
d = grib_power(decimal_scale_factor,10) ;
@ -641,7 +641,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
if (grib_get_nearest_smaller_value(a->parent->h,self->reference_value,min,&reference_value)
!=GRIB_SUCCESS) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"unable to find nearest_smaller_value of %g for %s",min,self->reference_value);
exit(GRIB_INTERNAL_ERROR);
}
@ -679,7 +679,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
buf_size += (vals_p/8) + (vals_p%8?1:0);
buf = (unsigned char*)grib_context_malloc_clear(a->parent->h->context,buf_size);
buf = (unsigned char*)grib_context_malloc_clear(a->context,buf_size);
buf_ref = buf;
buf_width = buf_ref + (7+(numberOfGroupsOfDataValues*bits_per_value))/8;
@ -709,8 +709,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
*/
grib_buffer_replace(a, buf,buf_size,1,1);
grib_context_free (a->parent->h->context,buf);
grib_context_free (a->parent->h->context,sec_val);
grib_context_free (a->context,buf);
grib_context_free (a->context,sec_val);
if((err = grib_set_long_internal(a->parent->h,self->bits_per_value,bits_per_value )) != GRIB_SUCCESS) return err;
if((err = grib_set_double_internal(a->parent->h,self->reference_value,reference_value )) != GRIB_SUCCESS) return err;
@ -749,11 +749,11 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val)
if (err) return err;
if (idx > size) return GRIB_INVALID_NEAREST;
values=(double*)grib_context_malloc_clear(a->parent->h->context,size*sizeof(double));
values=(double*)grib_context_malloc_clear(a->context,size*sizeof(double));
err=grib_get_double_array(a->parent->h,"codedValues",values,&size);
if (err) return err;
*val=values[idx];
grib_context_free(a->parent->h->context,values);
grib_context_free(a->context,values);
return err;
}

View File

@ -185,13 +185,13 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
}
primary_len = *len / expand_by;
primary_bitmap= (double*)grib_context_malloc_clear(a->parent->h->context,primary_len*sizeof(double));
primary_bitmap= (double*)grib_context_malloc_clear(a->context,primary_len*sizeof(double));
if(!primary_bitmap) return GRIB_OUT_OF_MEMORY;
secondary_len = *len ;
secondary_bitmap= (double*)grib_context_malloc_clear(a->parent->h->context,secondary_len*sizeof(double));
secondary_bitmap= (double*)grib_context_malloc_clear(a->context,secondary_len*sizeof(double));
if(!secondary_bitmap) {
grib_context_free(a->parent->h->context,primary_bitmap);
grib_context_free(a->context,primary_bitmap);
return GRIB_OUT_OF_MEMORY;
}
@ -227,8 +227,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
if(err == GRIB_SUCCESS)
err = grib_set_double_array_internal(a->parent->h,self->secondary_bitmap,secondary_bitmap,m);
grib_context_free(a->parent->h->context,primary_bitmap);
grib_context_free(a->parent->h->context,secondary_bitmap);
grib_context_free(a->context,primary_bitmap);
grib_context_free(a->context,secondary_bitmap);
if(err == GRIB_SUCCESS)
err = grib_set_long_internal(a->parent->h,self->number_of_values,*len * expand_by);

View File

@ -217,7 +217,7 @@ static int pack_double(grib_accessor* a, const double* cval, size_t *len)
case GRIB_SUCCESS:
break;
default:
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"unable to compute packing parameters\n");
grib_context_log(a->context,GRIB_LOG_ERROR,"unable to compute packing parameters\n");
return ret;
}
@ -241,17 +241,17 @@ static int pack_double(grib_accessor* a, const double* cval, size_t *len)
divisor = grib_power(-binary_scale_factor,2);
buflen = (((bits_per_value*n_vals)+7)/8)*sizeof(unsigned char);
buf = (unsigned char*)grib_context_buffer_malloc_clear(a->parent->h->context,buflen);
buf = (unsigned char*)grib_context_buffer_malloc_clear(a->context,buflen);
encoded = buf;
grib_encode_double_array(n_vals,val,bits_per_value,reference_value,decimal,divisor,encoded,&off);
grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG,
grib_context_log(a->context, GRIB_LOG_DEBUG,
"grib_accessor_data_g2simple_packing : pack_double : packing %s, %d values", a->name, n_vals);
grib_buffer_replace(a, buf, buflen,1,1);
grib_context_buffer_free(a->parent->h->context,buf);
grib_context_buffer_free(a->context,buf);
return ret;
}

View File

@ -202,12 +202,12 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
if((err = grib_get_long_internal(a->parent->h,self->pre_processing, &pre_processing)) != GRIB_SUCCESS){
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Accessor %s cannont gather value for %s error %d \n", a->name, self->pre_processing, err);
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannont gather value for %s error %d \n", a->name, self->pre_processing, err);
return err;
}
if((err = grib_get_double_internal(a->parent->h,self->pre_processing_parameter, &pre_processing_parameter)) != GRIB_SUCCESS){
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Accessor %s cannont gather value for %s error %d \n", a->name, self->pre_processing_parameter, err);
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannont gather value for %s error %d \n", a->name, self->pre_processing_parameter, err);
return err;
}

View File

@ -286,15 +286,15 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
switch (self->jpeg_lib) {
case OPENJPEG_LIB:
if ((err = grib_openjpeg_decode(a->parent->h->context,buf,&buflen,val,&n_vals)) != GRIB_SUCCESS)
if ((err = grib_openjpeg_decode(a->context,buf,&buflen,val,&n_vals)) != GRIB_SUCCESS)
return err;
break;
case JASPER_LIB:
if ((err = grib_jasper_decode(a->parent->h->context,buf,&buflen,val,&n_vals)) != GRIB_SUCCESS)
if ((err = grib_jasper_decode(a->context,buf,&buflen,val,&n_vals)) != GRIB_SUCCESS)
return err;
break;
default:
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"Unable to unpack. Invalid JPEG library.\n");
grib_context_log(a->context,GRIB_LOG_ERROR,"Unable to unpack. Invalid JPEG library.\n");
return GRIB_DECODING_ERROR;
}
@ -378,7 +378,7 @@ static int pack_double(grib_accessor* a, const double* cval, size_t *len)
case GRIB_SUCCESS:
break;
default:
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"unable to compute packing parameters\n");
grib_context_log(a->context,GRIB_LOG_ERROR,"unable to compute packing parameters\n");
return ret;
}
@ -402,7 +402,7 @@ static int pack_double(grib_accessor* a, const double* cval, size_t *len)
divisor = grib_power(-binary_scale_factor,2);
simple_packing_size = (((bits_per_value*n_vals)+7)/8)*sizeof(unsigned char);
buf = (unsigned char*)grib_context_malloc_clear(a->parent->h->context,simple_packing_size+EXTRA_BUFFER_SIZE);
buf = (unsigned char*)grib_context_malloc_clear(a->context,simple_packing_size+EXTRA_BUFFER_SIZE);
if(!buf) {
err = GRIB_OUT_OF_MEMORY;
goto cleanup;
@ -478,7 +478,7 @@ static int pack_double(grib_accessor* a, const double* cval, size_t *len)
/* See GRIB-438 */
if (bits_per_value == 0) {
const long bits_per_value_adjusted = 1;
grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG,
grib_context_log(a->context, GRIB_LOG_DEBUG,
"grib_accessor_class_data_jpeg2000_packing(%s) : bits per value was zero, changed to %d",
self->jpeg_lib==OPENJPEG_LIB ? "openjpeg" : "jasper", bits_per_value_adjusted);
bits_per_value = bits_per_value_adjusted;
@ -495,15 +495,15 @@ static int pack_double(grib_accessor* a, const double* cval, size_t *len)
switch (self->jpeg_lib) {
case OPENJPEG_LIB:
if ( (err = grib_openjpeg_encode(a->parent->h->context,&helper)) != GRIB_SUCCESS ) goto cleanup;
if ( (err = grib_openjpeg_encode(a->context,&helper)) != GRIB_SUCCESS ) goto cleanup;
break;
case JASPER_LIB:
if ( (err = grib_jasper_encode(a->parent->h->context,&helper)) != GRIB_SUCCESS ) goto cleanup;
if ( (err = grib_jasper_encode(a->context,&helper)) != GRIB_SUCCESS ) goto cleanup;
break;
}
if(helper.jpeg_length > simple_packing_size)
grib_context_log(a->parent->h->context, GRIB_LOG_WARNING,
grib_context_log(a->context, GRIB_LOG_WARNING,
"grib_accessor_data_jpeg2000_packing(%s) : jpeg data (%ld) larger than input data (%ld)",
self->jpeg_lib==OPENJPEG_LIB ? "openjpeg" : "jasper",
helper.jpeg_length, simple_packing_size);
@ -525,7 +525,7 @@ static int pack_double(grib_accessor* a, const double* cval, size_t *len)
cleanup:
grib_context_free(a->parent->h->context,buf);
grib_context_free(a->context,buf);
if(err == GRIB_SUCCESS)
err = grib_set_long_internal(a->parent->h,self->number_of_values, *len);
@ -536,14 +536,14 @@ static int pack_double(grib_accessor* a, const double* cval, size_t *len)
static int unpack_double(grib_accessor* a, double* val, size_t *len)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR,
grib_context_log(a->context, GRIB_LOG_ERROR,
"JPEG support not enabled.");
return GRIB_NOT_IMPLEMENTED;
}
static int pack_double(grib_accessor* a, const double* val, size_t *len)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR,
grib_context_log(a->context, GRIB_LOG_ERROR,
"JPEG support not enabled.");
return GRIB_NOT_IMPLEMENTED;
}
@ -562,10 +562,10 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val)
if (err) return err;
if (idx > size) return GRIB_INVALID_NEAREST;
values=(double*)grib_context_malloc_clear(a->parent->h->context,size*sizeof(double));
values=(double*)grib_context_malloc_clear(a->context,size*sizeof(double));
err=grib_get_double_array(a->parent->h,"codedValues",values,&size);
if (err) return err;
*val=values[idx];
grib_context_free(a->parent->h->context,values);
grib_context_free(a->context,values);
return err;
}

View File

@ -519,7 +519,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
if (grib_get_nearest_smaller_value(a->parent->h,self->reference_value,min,&reference_value)
!=GRIB_SUCCESS) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"unable to find nearest_smaller_value of %g for %s",min,self->reference_value);
exit(GRIB_INTERNAL_ERROR);
}
@ -537,7 +537,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
Assert(bits_per_value % 8 == 0);
#endif
bits8 = (bits_per_value+7)/8*8;
encoded = grib_context_buffer_malloc_clear(a->parent->h->context,bits8/8*n_vals);
encoded = grib_context_buffer_malloc_clear(a->context,bits8/8*n_vals);
if(!encoded) {
err = GRIB_OUT_OF_MEMORY;
@ -559,9 +559,9 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
}
/* buflen = n_vals*(bits_per_value/8);*/
grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG,
grib_context_log(a->context, GRIB_LOG_DEBUG,
"grib_accessor_data_png_packing : pack_double : packing %s, %d values", a->name, n_vals);
buf = grib_context_buffer_malloc_clear(a->parent->h->context,buflen);
buf = grib_context_buffer_malloc_clear(a->context,buflen);
if(!buf) {
err = GRIB_OUT_OF_MEMORY;
@ -641,7 +641,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
/*bytes=bit_depth/8;*/
bytes = bits8/8;
rows = grib_context_buffer_malloc_clear(a->parent->h->context,sizeof(png_bytep)*height);
rows = grib_context_buffer_malloc_clear(a->context,sizeof(png_bytep)*height);
rows = malloc(height*sizeof(png_bytep));
for (j=0;j<height;j++)
@ -661,9 +661,9 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
png_destroy_write_struct(&png, info?&info:NULL);
grib_context_buffer_free(a->parent->h->context,buf);
grib_context_buffer_free(a->parent->h->context,encoded);
grib_context_buffer_free(a->parent->h->context,rows);
grib_context_buffer_free(a->context,buf);
grib_context_buffer_free(a->context,encoded);
grib_context_buffer_free(a->context,rows);
if(err == GRIB_SUCCESS)
err = grib_set_long_internal(a->parent->h,self->number_of_values, *len);
@ -674,14 +674,14 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
static int unpack_double(grib_accessor* a, double* val, size_t *len)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR,
grib_context_log(a->context, GRIB_LOG_ERROR,
"grib_accessor_data_png_packing: PNG support not enabled.");
return GRIB_NOT_IMPLEMENTED;
}
static int pack_double(grib_accessor* a, const double* val, size_t *len)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR,
grib_context_log(a->context, GRIB_LOG_ERROR,
"grib_accessor_data_png_packing: PNG support not enabled.");
return GRIB_NOT_IMPLEMENTED;
}

View File

@ -203,7 +203,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
if(*len < nvals)
return GRIB_ARRAY_TOO_SMALL;
code=grib_ieee_decode_array(a->parent->h->context,buf,nvals,bytes,val);
code=grib_ieee_decode_array(a->context,buf,nvals,bytes,val);
*len = nvals;
@ -255,7 +255,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
bufsize = bytes*inlen;
buffer = (unsigned char*)grib_context_malloc(a->parent->h->context, bufsize);
buffer = (unsigned char*)grib_context_malloc(a->context, bufsize);
if(!buffer)
{
@ -263,7 +263,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
goto clean_up;
}
code=grib_ieee_encode_array(a->parent->h->context,values,inlen,bytes,buffer);
code=grib_ieee_encode_array(a->context,values,inlen,bytes,buffer);
clean_up:
if(free_buffer) free(buffer);
@ -271,7 +271,7 @@ clean_up:
grib_buffer_replace(a, buffer, bufsize,1,1);
grib_context_buffer_free(a->parent->h->context,buffer);
grib_context_buffer_free(a->context,buffer);
code = grib_set_long(a->parent->h,self->number_of_values, inlen);
if(code==GRIB_READ_ONLY) code=0;
@ -322,7 +322,7 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) {
nvals = 1;
buf+=pos;
ret=grib_ieee_decode_array(a->parent->h->context,buf,nvals,bytes,val);
ret=grib_ieee_decode_array(a->context,buf,nvals,bytes,val);
return ret;
}

View File

@ -191,28 +191,28 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
if((err = grib_get_size(a->parent->h,self->secondary_bitmap,&secondary_len)) != GRIB_SUCCESS)
return err;
primary_vals = (double*)grib_context_malloc(a->parent->h->context,primary_len*sizeof(double));
primary_vals = (double*)grib_context_malloc(a->context,primary_len*sizeof(double));
if(!primary_vals)
return GRIB_OUT_OF_MEMORY;
secondary_vals = (double*)grib_context_malloc(a->parent->h->context,secondary_len*sizeof(double));
secondary_vals = (double*)grib_context_malloc(a->context,secondary_len*sizeof(double));
if(!secondary_vals)
{
grib_context_free(a->parent->h->context,primary_vals);
grib_context_free(a->context,primary_vals);
return GRIB_OUT_OF_MEMORY;
}
if((err = grib_get_double_array_internal(a->parent->h,self->primary_bitmap,primary_vals,&primary_len)) != GRIB_SUCCESS)
{
grib_context_free(a->parent->h->context,secondary_vals);
grib_context_free(a->parent->h->context,primary_vals);
grib_context_free(a->context,secondary_vals);
grib_context_free(a->context,primary_vals);
return err;
}
if((err = grib_get_double_array_internal(a->parent->h,self->secondary_bitmap,secondary_vals,&secondary_len)) != GRIB_SUCCESS)
{
grib_context_free(a->parent->h->context,secondary_vals);
grib_context_free(a->parent->h->context,primary_vals);
grib_context_free(a->context,secondary_vals);
grib_context_free(a->context,primary_vals);
return err;
}
@ -240,8 +240,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
*len = n_vals;
grib_context_free(a->parent->h->context,primary_vals);
grib_context_free(a->parent->h->context,secondary_vals);
grib_context_free(a->context,primary_vals);
grib_context_free(a->context,secondary_vals);
return err;
}

View File

@ -215,7 +215,7 @@ static int value_count(grib_accessor* a,long* count)
return ret;
if (pen_j != pen_k || pen_j!=pen_m ) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"pen_j=%ld, pen_k=%ld, pen_m=%ld\n",pen_j,pen_k,pen_m);
grib_context_log(a->context,GRIB_LOG_ERROR,"pen_j=%ld, pen_k=%ld, pen_m=%ld\n",pen_j,pen_k,pen_m);
Assert ((pen_j == pen_k) && (pen_j == pen_m));
}
*count=(pen_j+1)*(pen_j+2)-(sub_j+1)*(sub_j+2);
@ -350,7 +350,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
s = grib_power(binary_scale_factor,2);
d = grib_power(-decimal_scale_factor,10) ;
scals = (double*)grib_context_malloc(a->parent->h->context,maxv*sizeof(double));
scals = (double*)grib_context_malloc(a->context,maxv*sizeof(double));
Assert(scals);
scals[0] = 0;
@ -403,7 +403,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
val[i++] *= d;
}
grib_context_free(a->parent->h->context,scals);
grib_context_free(a->context,scals);
return ret;
}

View File

@ -206,7 +206,7 @@ static int value_count(grib_accessor* a,long* count)
return ret;
if (sub_j != sub_k || sub_j!=sub_m ) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"sub_j=%ld, sub_k=%ld, sub_m=%ld\n",sub_j,sub_k,sub_m);
grib_context_log(a->context,GRIB_LOG_ERROR,"sub_j=%ld, sub_k=%ld, sub_m=%ld\n",sub_j,sub_k,sub_m);
Assert ((sub_j == sub_k) && (sub_j == sub_m));
}
*count=(sub_j+1)*(sub_j+2);
@ -330,7 +330,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
s = grib_power(binary_scale_factor,2);
d = grib_power(-decimal_scale_factor,10) ;
scals = (double*)grib_context_malloc(a->parent->h->context,maxv*sizeof(double));
scals = (double*)grib_context_malloc(a->context,maxv*sizeof(double));
Assert(scals);
if((ret = grib_get_double_internal(a->parent->h,self->laplacianOperator,&laplacianOperator))
!= GRIB_SUCCESS)
@ -392,7 +392,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
val[i++] *= d;
}
grib_context_free(a->parent->h->context,scals);
grib_context_free(a->context,scals);
return ret;

View File

@ -256,7 +256,7 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val)
s = grib_power(binary_scale_factor,2);
d = grib_power(-decimal_scale_factor,10) ;
grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG,
grib_context_log(a->context, GRIB_LOG_DEBUG,
"grib_accessor_data_simple_packing: unpack_double_element: creating %s, %d values (idx=%ld)",
a->name, n_vals, idx);
@ -266,7 +266,7 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val)
if(bits_per_value%8)
{
grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG,
grib_context_log(a->context, GRIB_LOG_DEBUG,
"unpack_double_element: calling outline function : bpv %d, rv : %g, sf : %d, dsf : %d ",
bits_per_value,reference_value,binary_scale_factor, decimal_scale_factor);
pos=idx*bits_per_value;
@ -374,7 +374,7 @@ static int _unpack_double(grib_accessor* a, double* val, size_t *len,unsigned c
s = grib_power(binary_scale_factor,2);
d = grib_power(-decimal_scale_factor,10) ;
grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG,
grib_context_log(a->context, GRIB_LOG_DEBUG,
"grib_accessor_data_simple_packing: unpack_double : creating %s, %d values",
a->name, n_vals);
@ -382,7 +382,7 @@ static int _unpack_double(grib_accessor* a, double* val, size_t *len,unsigned c
/*Assert(((bits_per_value*n_vals)/8) < (1<<29));*/ /* See GRIB-787 */
grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG,
grib_context_log(a->context, GRIB_LOG_DEBUG,
"unpack_double: calling outline function : bpv %d, rv : %g, sf : %d, dsf : %d ",
bits_per_value,reference_value,binary_scale_factor, decimal_scale_factor);
grib_decode_double_array(buf,&pos,bits_per_value,reference_value,s,d,n_vals,val);
@ -482,7 +482,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
double range=0;
double minrange=0,maxrange=0;
long changing_precision=0;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
decimal_scale_factor=0;
@ -525,7 +525,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
int large_constant_fields = 0;
if (grib_get_nearest_smaller_value(a->parent->h,self->reference_value,val[0],&reference_value)
!=GRIB_SUCCESS) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"unable to find nearest_smaller_value of %g for %s",min,self->reference_value);
return GRIB_INTERNAL_ERROR;
}
@ -581,7 +581,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
this is a safe way of fixing the problem */
if ( changing_precision==0 && bits_per_value==0 && decimal_scale_factor_get==0) {
grib_context_log(a->parent->h->context,GRIB_LOG_WARNING,
grib_context_log(a->context,GRIB_LOG_WARNING,
"%s==0 and %s==0 (setting %s=24)",
self->bits_per_value,
self->decimal_scale_factor,
@ -606,7 +606,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
/* See GRIB-540 for why we use ceil */
err = number_of_bits( (unsigned long)ceil(fabs(max-min)), &bits_per_value );
if (err) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"Range of values too large. Try a smaller value for decimal precision (less than %d)",
decimal_scale_factor);
return err;
@ -617,7 +617,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
return err;
if (grib_get_nearest_smaller_value(a->parent->h,self->reference_value,min,&reference_value)
!=GRIB_SUCCESS) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"unable to find nearest_smaller_value of %g for %s",min,self->reference_value);
return GRIB_INTERNAL_ERROR;
}
@ -633,7 +633,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
/* divisor=1; */
if (grib_get_nearest_smaller_value(a->parent->h,self->reference_value,min,&reference_value)
!=GRIB_SUCCESS) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"unable to find nearest_smaller_value of %g for %s",min,self->reference_value);
return GRIB_INTERNAL_ERROR;
}
@ -665,7 +665,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
if (grib_get_nearest_smaller_value(a->parent->h,self->reference_value,
min,&reference_value)!=GRIB_SUCCESS) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"unable to find nearest_smaller_value of %g for %s",min,self->reference_value);
return GRIB_INTERNAL_ERROR;
}

View File

@ -173,7 +173,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
size_t size=0;
int ret=0;
grib_accessor_decimal_precision* self= (grib_accessor_decimal_precision*)a;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
grib_handle* h=a->parent->h;
if (!self->values) {

View File

@ -289,7 +289,7 @@ static int unpack_string (grib_accessor* a, char* buffer, size_t *len)
size_t rsize=0;
int i=0;
grib_trie* dictionary=load_dictionary(a->parent->h->context,a,&err);
grib_trie* dictionary=load_dictionary(a->context,a,&err);
if (err) return err;
if((err=grib_get_string_internal(a->parent->h,self->key,key,&size)) != GRIB_SUCCESS) {

View File

@ -155,12 +155,12 @@ static int unpack_string(grib_accessor*a , char* v, size_t *len){
l = strlen(repres)+1;
if(l >*len ){
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "grib_accessor_long : unpack_string : Buffer too small for %s ", a->name );
grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_long : unpack_string : Buffer too small for %s ", a->name );
*len = l;
return GRIB_BUFFER_TOO_SMALL;
}
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG, "grib_accessor_long: Casting double %s to string ", a->name);
grib_context_log(a->context,GRIB_LOG_DEBUG, "grib_accessor_long: Casting double %s to string ", a->name);
*len = l;
@ -194,7 +194,7 @@ static int compare(grib_accessor* a, grib_accessor* b) {
if (alen != blen) return GRIB_COUNT_MISMATCH;
aval=(double*)grib_context_malloc(a->parent->h->context,alen*sizeof(double));
aval=(double*)grib_context_malloc(a->context,alen*sizeof(double));
bval=(double*)grib_context_malloc(b->parent->h->context,blen*sizeof(double));
grib_unpack_double(a,aval,&alen);
@ -206,7 +206,7 @@ static int compare(grib_accessor* a, grib_accessor* b) {
alen--;
}
grib_context_free(a->parent->h->context,aval);
grib_context_free(a->context,aval);
grib_context_free(b->parent->h->context,bval);
return retval;

View File

@ -153,7 +153,7 @@ static int unpack_long (grib_accessor* a, long* val, size_t *len)
int ret = 0;
size_t size=0;
long* ar=NULL;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
if(*len < 1){
ret = GRIB_ARRAY_TOO_SMALL;
@ -186,7 +186,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
int ret = 0;
size_t size=0;
long* ar=NULL;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
if(*len < 1){
ret = GRIB_ARRAY_TOO_SMALL;

View File

@ -208,7 +208,7 @@ static size_t __expand(grib_accessor* a,bufr_descriptors_array* unexpanded,bufr_
bufr_descriptor* urc=NULL;
int idx;
bufr_descriptor* u0=NULL;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
bufr_descriptor* us=NULL;
bufr_descriptors_array* inner_expanded=NULL;
bufr_descriptors_array* inner_unexpanded=NULL;
@ -460,7 +460,7 @@ static size_t __expand(grib_accessor* a,bufr_descriptors_array* unexpanded,bufr_
static bufr_descriptors_array* _expand(grib_accessor* a,bufr_descriptors_array* unexpanded,change_coding_params* ccp,int *err)
{
bufr_descriptors_array* expanded=NULL;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
#if MYDEBUG
int idepth;
#endif
@ -517,7 +517,7 @@ static int expand(grib_accessor* a)
long* u=0;
change_coding_params ccp;
bufr_descriptors_array* unexpanded=NULL;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
if (!self->do_expand) {
return err;
@ -581,11 +581,11 @@ static int unpack_double (grib_accessor* a, double* val, size_t *len) {
size_t expandedSize;
if (self->rank!=2) {
long* lval=(long*)grib_context_malloc_clear(a->parent->h->context,*len*sizeof(long));
long* lval=(long*)grib_context_malloc_clear(a->context,*len*sizeof(long));
ret=unpack_long(a,lval,len);
if (ret) return ret;
for (i=0;i<*len;i++) val[i]=(double)lval[i];
grib_context_free(a->parent->h->context,lval);
grib_context_free(a->context,lval);
} else {
ret=expand(a);
if (ret) return ret;
@ -593,7 +593,7 @@ static int unpack_double (grib_accessor* a, double* val, size_t *len) {
expandedSize=grib_bufr_descriptors_array_used_size(self->expanded);
if(*len < expandedSize)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR,
grib_context_log(a->context, GRIB_LOG_ERROR,
" wrong size (%ld) for %s it contains %d values ",*len, a->name , expandedSize);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
@ -617,7 +617,7 @@ static int unpack_long (grib_accessor* a, long* val, size_t *len)
if(*len < rlen)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR,
grib_context_log(a->context, GRIB_LOG_ERROR,
" wrong size (%ld) for %s it contains %d values ",*len, a->name , rlen);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
@ -657,7 +657,7 @@ static int value_count(grib_accessor* a,long* rlen)
{
grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a;
int ret=0;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
*rlen=0;
ret=expand(a);

View File

@ -148,7 +148,7 @@ static int unpack_long (grib_accessor* a, long* val, size_t *len)
unsigned char dat = 0;
if(*len < 1)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -165,7 +165,7 @@ static int pack_long (grib_accessor* a, const long *val, size_t *len)
int ret = 0;
if(*len < 1)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -222,18 +222,18 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
ret = grib_get_double_internal(a->parent->h, self->first,&first);
if(ret != GRIB_SUCCESS) {
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Accessor %s cannont gather value for %s error %d \n", a->name, self->first, ret);
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannont gather value for %s error %d \n", a->name, self->first, ret);
return ret;
}
ret = grib_get_double_internal(a->parent->h, self->last,&last);
if(ret != GRIB_SUCCESS){
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Accessor %s cannont gather value for %s error %d \n", a->name, self->last, ret);
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannont gather value for %s error %d \n", a->name, self->last, ret);
return ret;
}
if((ret = grib_get_long_internal(a->parent->h, self->directionIncrementGiven,&directionIncrementGiven))
!= GRIB_SUCCESS){
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Accessor %s cannont gather value for %s error %d \n", a->name, self->directionIncrementGiven, ret);
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannont gather value for %s error %d \n", a->name, self->directionIncrementGiven, ret);
return ret;
}
@ -249,7 +249,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
ret = grib_set_long_internal(a->parent->h, self->numberOfPoints,numberOfPoints);
if(ret )
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Accessor %s cannont pack value for %s error %d \n", a->name, self->numberOfPoints, ret);
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannont pack value for %s error %d \n", a->name, self->numberOfPoints, ret);
grib_get_long_internal(a->parent->h, self->numberOfPoints,&codedNumberOfPoints);
@ -257,11 +257,11 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
ret = grib_set_long_internal(a->parent->h, self->directionIncrement,directionIncrement);
if(ret )
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Accessor %s cannont pack value for %s error %d \n", a->name, self->directionIncrement, ret);
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannont pack value for %s error %d \n", a->name, self->directionIncrement, ret);
ret = grib_set_long_internal(a->parent->h, self->directionIncrementGiven,directionIncrementGiven);
if(ret )
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Accessor %s cannont pack value for %s error %d \n", a->name, self->directionIncrementGiven, ret);
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannont pack value for %s error %d \n", a->name, self->directionIncrementGiven, ret);
#if 0
printf("pack -- %s=%ld %s=%ld %s=%f %s=%f %s=%ld codedNumberOfPoints=%ld %s=%f\n",

View File

@ -195,7 +195,7 @@ static int pack_long(grib_accessor* a, const long* val,size_t *len)
int ret;
tlen = *val;
if((tlen < 0x800000 || !a->parent->h->context->gribex_mode_on) && tlen < 0xFFFFFF )
if((tlen < 0x800000 || !a->context->gribex_mode_on) && tlen < 0xFFFFFF )
{
/* printf("ENCODING small grib total = %ld\n",tlen); */
/*return super->pack_long(a,val,len);*/

View File

@ -220,7 +220,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t *len)
if(ret) return ret;
if(*len < 60)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, " Buffer too smalle for %s (%d) ", a->name ,*len);
grib_context_log(a->context, GRIB_LOG_ERROR, " Buffer too smalle for %s (%d) ", a->name ,*len);
len = 0;
return GRIB_BUFFER_TOO_SMALL;
}

View File

@ -167,7 +167,7 @@ static int pack_double(grib_accessor* a, const double* val,size_t *len){
!= GRIB_SUCCESS)
return err;
buf = (unsigned char*)grib_context_malloc_clear(a->parent->h->context,tlen);
buf = (unsigned char*)grib_context_malloc_clear(a->context,tlen);
if(!buf) return GRIB_OUT_OF_MEMORY;
pos=0;
for(i=0;i<*len;i++)
@ -186,7 +186,7 @@ static int pack_double(grib_accessor* a, const double* val,size_t *len){
grib_buffer_replace(a, buf, tlen,1,1);
grib_context_free(a->parent->h->context,buf);
grib_context_free(a->context,buf);
return GRIB_SUCCESS;
}
@ -199,7 +199,7 @@ static int value_count(grib_accessor* a,long* count)
int err;
if ((err=grib_get_long_internal(a->parent->h, self->unusedBits, &tlen)) != GRIB_SUCCESS)
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "grib_accessor_class_bitmap.value_count : cannot get %s err=%d",self->unusedBits,err);
grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_class_bitmap.value_count : cannot get %s err=%d",self->unusedBits,err);
*count = (a->length*8)-tlen;
return err;
@ -216,13 +216,13 @@ static int unpack_bytes(grib_accessor* a, unsigned char* val, size_t *len)
if(*len < (size_t)length )
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it is %d bytes long\n", a->name ,length );
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it is %d bytes long\n", a->name ,length );
*len = length;
return GRIB_ARRAY_TOO_SMALL;
}
if ((err=grib_get_long_internal(a->parent->h, self->unusedBits, &tlen)) != GRIB_SUCCESS)
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR,
grib_context_log(a->context, GRIB_LOG_ERROR,
"grib_accessor_class_bitmap.unpack_bytes : cannot get %s err=%d",self->unusedBits,err);
length-= tlen/8;

View File

@ -212,7 +212,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
long d = grib_julian_to_date((long)grib_date_to_julian(v));
if(v != d)
{
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"grib_accessor_g1date: pack_long invalid date %ld, changed to %ld",v,d);
grib_context_log(a->context,GRIB_LOG_ERROR,"grib_accessor_g1date: pack_long invalid date %ld, changed to %ld",v,d);
return GRIB_ENCODING_ERROR;
}
}

View File

@ -146,7 +146,7 @@ static void init(grib_accessor* a,const long l, grib_arguments* c)
a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN;
self->number_of_elements=6;
self->v=(double*)grib_context_malloc(a->parent->h->context,
self->v=(double*)grib_context_malloc(a->context,
sizeof(double)*self->number_of_elements);
a->length=0;
@ -229,7 +229,7 @@ static int compare(grib_accessor* a, grib_accessor* b) {
if (alen != blen) return GRIB_COUNT_MISMATCH;
aval=(double*)grib_context_malloc(a->parent->h->context,alen*sizeof(double));
aval=(double*)grib_context_malloc(a->context,alen*sizeof(double));
bval=(double*)grib_context_malloc(b->parent->h->context,blen*sizeof(double));
b->dirty=1;
@ -243,7 +243,7 @@ static int compare(grib_accessor* a, grib_accessor* b) {
alen--;
}
grib_context_free(a->parent->h->context,aval);
grib_context_free(a->context,aval);
grib_context_free(b->parent->h->context,bval);
return retval;

View File

@ -199,7 +199,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
fcmonth++;
if(gribForecastMonth != 0 && gribForecastMonth!=fcmonth) {
grib_context_log(a->parent->h->context,GRIB_LOG_FATAL,"%s=%ld (%s-%s)=%ld",self->fcmonth,
grib_context_log(a->context,GRIB_LOG_FATAL,"%s=%ld (%s-%s)=%ld",self->fcmonth,
gribForecastMonth,self->base_date,self->verification_yearmonth,fcmonth);
Assert(gribForecastMonth == fcmonth);
}

View File

@ -322,7 +322,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t *len)
if (error_on_units) {
grib_get_long_internal(a->parent->h,self->unit,&unit);
grib_set_long_internal(a->parent->h,self->step_unit,unit);
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"unable to represent the step in %s\n Hint: try changing the step units",
step_unit_string);
}
@ -375,7 +375,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t *len)
}
}
else {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR, "Unknown stepType=[%s] timeRangeIndicator=[%ld]",stepType,timeRangeIndicator);
grib_context_log(a->context,GRIB_LOG_ERROR, "Unknown stepType=[%s] timeRangeIndicator=[%ld]",stepType,timeRangeIndicator);
return GRIB_NOT_IMPLEMENTED;
}

View File

@ -187,7 +187,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
key=(char*)self->stream;
break;
default :
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"invalid first argument of g2_mars_labeling in %s",a->name);
return GRIB_INTERNAL_ERROR;
break;
@ -212,7 +212,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t *len)
key=(char*)self->stream;
break;
default :
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"invalid first argument of g2_mars_labeling in %s",a->name);
return GRIB_INTERNAL_ERROR;
break;
@ -383,7 +383,7 @@ static int extra_set(grib_accessor* a,long val)
typeOfGeneratingProcess=4;
break;
default :
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"unknown mars.type %d",(int)val);
grib_context_log(a->context,GRIB_LOG_ERROR,"unknown mars.type %d",(int)val);
return GRIB_ENCODING_ERROR;
}
case 2:
@ -402,7 +402,7 @@ static int extra_set(grib_accessor* a,long val)
}
break;
default :
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"invalid first argument of g2_mars_labeling in %s",a->name);
return GRIB_INTERNAL_ERROR;
break;
@ -444,7 +444,7 @@ static int pack_string(grib_accessor* a, const char* val, size_t *len)
key=(char*)self->stream;
break;
default :
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"invalid first argument of g2_mars_labeling in %s",a->name);
return GRIB_INTERNAL_ERROR;
break;
@ -476,7 +476,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
key=(char*)self->stream;
break;
default :
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"invalid first argument of g2_mars_labeling in %s",a->name);
return GRIB_INTERNAL_ERROR;
break;
@ -512,14 +512,14 @@ static int get_native_type(grib_accessor* a)
key=(char*)self->stream;
break;
default :
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"invalid first argument of g2_mars_labeling in %s",a->name);
return GRIB_INTERNAL_ERROR;
break;
}
ret=grib_get_native_type(a->parent->h,key,&type);
if (ret) grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
if (ret) grib_context_log(a->context,GRIB_LOG_ERROR,
"unable to get native type for %s",key);
return type;
}

View File

@ -172,7 +172,7 @@ static int pack_double(grib_accessor* a, const double* val,size_t *len){
!= GRIB_SUCCESS)
return err;
buf = (unsigned char*)grib_context_malloc_clear(a->parent->h->context,tlen);
buf = (unsigned char*)grib_context_malloc_clear(a->context,tlen);
if(!buf) return GRIB_OUT_OF_MEMORY;
pos=0;
for(i=0;i<*len;i++)
@ -186,13 +186,13 @@ static int pack_double(grib_accessor* a, const double* val,size_t *len){
}
if((err = grib_set_long_internal(a->parent->h, self->numberOfValues,*len )) != GRIB_SUCCESS) {
grib_context_free(a->parent->h->context,buf);
grib_context_free(a->context,buf);
return err;
}
grib_buffer_replace(a, buf, tlen,1,1);
grib_context_free(a->parent->h->context,buf);
grib_context_free(a->context,buf);
return GRIB_SUCCESS;
}

View File

@ -348,7 +348,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
sub_division = 1000000;
if(!is_ok(val,v,basic_angle,sub_division))
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG,"Grid cannot be coded with any loss of precision");
grib_context_log(a->context,GRIB_LOG_DEBUG,"Grid cannot be coded with any loss of precision");
}
if(basic_angle == 1 && sub_division == 1000000)

View File

@ -160,7 +160,7 @@ static int pack_long (grib_accessor* a, const long* val, size_t *len)
int ret=0;
size_t size=0;
double* values;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
grib_handle* h=a->parent->h;
grib_accessor_gds_is_present* self = (grib_accessor_gds_is_present*)a;

View File

@ -209,7 +209,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
}
if(number_of_values > 0){
coded_vals = (double*)grib_context_malloc(a->parent->h->context,number_of_values*sizeof(double));
coded_vals = (double*)grib_context_malloc(a->context,number_of_values*sizeof(double));
if(coded_vals == NULL)
return GRIB_OUT_OF_MEMORY;
@ -226,7 +226,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
*len = number_of_points;
grib_context_free(a->parent->h->context,coded_vals);
grib_context_free(a->context,coded_vals);
return err;
}
@ -256,11 +256,11 @@ static int pack_double(grib_accessor* a, const double* val,size_t *len){
if((err = grib_get_double_internal(a->parent->h, self->missing_value, &miss_values)) != GRIB_SUCCESS)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "grib_accessor_class_bitmap : pack_double : Cannot unpack %s err=%d ",self->missing_value,err);
grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_class_bitmap : pack_double : Cannot unpack %s err=%d ",self->missing_value,err);
return err;
}
buf = grib_context_malloc_clear(a->parent->h->context,tlen);
buf = grib_context_malloc_clear(a->context,tlen);
if(!buf) return GRIB_OUT_OF_MEMORY;
pos=0;
for(i=0;i<*len;i++)
@ -274,15 +274,15 @@ static int pack_double(grib_accessor* a, const double* val,size_t *len){
}
if((err = grib_set_long_internal(a->parent->h, self->unusedBits,tlen*8 - *len )) != GRIB_SUCCESS) {
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "grib_accessor_class_bitmap : pack_double : Cannot pack %s err=%d ",self->unusedBits,err);
grib_context_free(a->parent->h->context,buf);
grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_class_bitmap : pack_double : Cannot pack %s err=%d ",self->unusedBits,err);
grib_context_free(a->context,buf);
return err;
}
grib_buffer_replace(a, buf, tlen,1,1);
grib_context_free(a->parent->h->context,buf);
grib_context_free(a->context,buf);
return GRIB_SUCCESS;
}

View File

@ -144,7 +144,7 @@ static void init(grib_accessor* a,const long len, grib_arguments* param)
if (a->flags & GRIB_ACCESSOR_FLAG_TRANSIENT) {
a->length = 0;
if (!a->vvalue)
a->vvalue = (grib_virtual_value*)grib_context_malloc_clear(a->parent->h->context,sizeof(grib_virtual_value));
a->vvalue = (grib_virtual_value*)grib_context_malloc_clear(a->context,sizeof(grib_virtual_value));
a->vvalue->type=grib_accessor_get_native_type(a);
a->vvalue->length=len;
if (act->default_value!=NULL) {
@ -171,7 +171,7 @@ static void init(grib_accessor* a,const long len, grib_arguments* param)
len = sizeof(tmp);
p = grib_expression_evaluate_string(a->parent->h,expression,tmp,&len,&ret);
if (ret != GRIB_SUCCESS) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"unable to evaluate %s as string",a->name);
grib_context_log(a->context,GRIB_LOG_ERROR,"unable to evaluate %s as string",a->name);
Assert(0);
}
len = strlen(p)+1;
@ -225,7 +225,7 @@ static long byte_count(grib_accessor* a)
}
static int get_native_type(grib_accessor* a){
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"Accessor %s [%s] must implement 'get_native_type'", a->name,a->cclass->name);
return GRIB_TYPE_UNDEFINED;
}
@ -244,7 +244,7 @@ static int unpack_bytes(grib_accessor* a, unsigned char* val, size_t *len)
if(*len < length )
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it is %d bytes long\n", a->name ,length );
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it is %d bytes long\n", a->name ,length );
*len = length;
return GRIB_ARRAY_TOO_SMALL;
}
@ -275,7 +275,7 @@ static int unpack_long (grib_accessor* a, long* v, size_t *len){
size_t l = 1;
grib_unpack_double (a , &val, &l);
*v = (long)val;
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG, " Casting double %s to long", a->name);
grib_context_log(a->context,GRIB_LOG_DEBUG, " Casting double %s to long", a->name);
return GRIB_SUCCESS;
}
@ -290,7 +290,7 @@ static int unpack_long (grib_accessor* a, long* v, size_t *len){
if(*last == 0)
{
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG, " Casting string %s to long", a->name);
grib_context_log(a->context,GRIB_LOG_DEBUG, " Casting string %s to long", a->name);
return GRIB_SUCCESS;
}
}
@ -306,7 +306,7 @@ static int unpack_double (grib_accessor* a, double*v, size_t *len){
size_t l = 1;
grib_unpack_long (a , &val, &l);
*v = val;
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG, " Casting long %s to double", a->name);
grib_context_log(a->context,GRIB_LOG_DEBUG, " Casting long %s to double", a->name);
return GRIB_SUCCESS;
}
@ -321,7 +321,7 @@ static int unpack_double (grib_accessor* a, double*v, size_t *len){
if(*last == 0)
{
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG, " Casting string %s to long", a->name);
grib_context_log(a->context,GRIB_LOG_DEBUG, " Casting string %s to long", a->name);
return GRIB_SUCCESS;
}
}
@ -338,7 +338,7 @@ static int unpack_string(grib_accessor*a , char* v, size_t *len){
grib_unpack_double (a , &val, &l);
sprintf(v,"%g",val);
*len = strlen(v);
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG, " Casting double %s to string", a->name);
grib_context_log(a->context,GRIB_LOG_DEBUG, " Casting double %s to string", a->name);
return GRIB_SUCCESS;
}
@ -349,7 +349,7 @@ static int unpack_string(grib_accessor*a , char* v, size_t *len){
grib_unpack_long (a , &val, &l);
sprintf(v,"%ld",val);
*len = strlen(v);
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG, " Casting long %s to string \n", a->name);
grib_context_log(a->context,GRIB_LOG_DEBUG, " Casting long %s to string \n", a->name);
return GRIB_SUCCESS;
}
@ -362,7 +362,7 @@ static int unpack_string_array(grib_accessor*a , char** v, size_t *len){
err= _grib_get_string_length(a,&length);
if (err) return err;
v[0]=(char*)grib_context_malloc_clear(a->parent->h->context,length);
v[0]=(char*)grib_context_malloc_clear(a->context,length);
grib_unpack_string(a,v[0],&length);
*len=1;
@ -383,7 +383,7 @@ static int pack_expression(grib_accessor* a, grib_expression *e){
len = 1;
ret = grib_expression_evaluate_long(a->parent->h,e,&lval);
if (ret != GRIB_SUCCESS) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"unable to set %s as long",a->name);
grib_context_log(a->context,GRIB_LOG_ERROR,"unable to set %s as long",a->name);
return ret;
}
return grib_pack_long(a,&lval,&len);
@ -399,7 +399,7 @@ static int pack_expression(grib_accessor* a, grib_expression *e){
len = sizeof(tmp);
cval = grib_expression_evaluate_string(a->parent->h,e,tmp,&len,&ret);
if (ret != GRIB_SUCCESS) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"unable to set %s as string",a->name);
grib_context_log(a->context,GRIB_LOG_ERROR,"unable to set %s as string",a->name);
return ret;
}
len = strlen(cval);
@ -411,7 +411,7 @@ static int pack_expression(grib_accessor* a, grib_expression *e){
}
static int pack_long(grib_accessor* a, const long* v, size_t *len){
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
if(a->cclass->pack_double && a->cclass->pack_double != &pack_double)
{
int i=0,ret=0;
@ -432,7 +432,7 @@ static int pack_long(grib_accessor* a, const long* v, size_t *len){
}
static int pack_double(grib_accessor* a, const double *v, size_t *len){
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
if(a->cclass->pack_long && a->cclass->pack_long != &pack_long)
{
int i=0,ret=0;
@ -470,7 +470,7 @@ static int pack_string(grib_accessor*a , const char* v, size_t *len){
return grib_pack_long (a , &val, &l);
}
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
" Should not grib_pack %s as string", a->name);
return GRIB_NOT_IMPLEMENTED;
}
@ -506,7 +506,7 @@ static int notify_change(grib_accessor* self,grib_accessor* observed)
static void update_size(grib_accessor* a,size_t s)
{
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"Accessor %s [%s] must implement 'update_size'", a->name,a->cclass->name);
Assert(0 == 1);
}
@ -544,7 +544,7 @@ static int is_missing(grib_accessor* a)
if (a->flags & GRIB_ACCESSOR_FLAG_TRANSIENT) {
if (a->vvalue == NULL) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"%s internal error (flags=0x%X)",a->name,a->flags);
grib_context_log(a->context,GRIB_LOG_ERROR,"%s internal error (flags=0x%X)",a->name,a->flags);
}
Assert(a->vvalue!=NULL);
return a->vvalue->missing;

View File

@ -182,7 +182,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
double* lats;
long factor, plpresent=0;
long max_pl=0; /* max. element of pl array */
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
if (self->basic_angle && self->subdivision) {
@ -285,7 +285,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
double ddi,dlonlast;
double dfactor,dNi;
long plpresent=0;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
if (*val == 0) return ret;

View File

@ -149,7 +149,7 @@ static void init(grib_accessor* a, const long len , grib_arguments* arg )
const char *s=grib_arguments_get_string(a->parent->h,arg,0);
if (s && strlen(s) > 1) {
grib_context_log(a->parent->h->context,GRIB_LOG_WARNING,
grib_context_log(a->context,GRIB_LOG_WARNING,
"Using only first character as group end of %s not the string %s",a->name,s);
}
@ -197,7 +197,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t *len)
if(len[0] < (a->length+1))
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%d) for %s it contains %d values ", len[0], a->name , a->length+1 );
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%d) for %s it contains %d values ", len[0], a->name , a->length+1 );
len[0] = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -216,12 +216,12 @@ static int pack_string(grib_accessor* a, const char* val, size_t *len)
}
static int pack_long(grib_accessor* a, const long* v, size_t *len){
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR, " Should not pack %s as long", a->name);
grib_context_log(a->context,GRIB_LOG_ERROR, " Should not pack %s as long", a->name);
return GRIB_NOT_IMPLEMENTED;
}
static int pack_double(grib_accessor* a, const double*v, size_t *len){
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR, " Should not pack %s as double", a->name);
grib_context_log(a->context,GRIB_LOG_ERROR, " Should not pack %s as double", a->name);
return GRIB_NOT_IMPLEMENTED;
}
@ -247,7 +247,7 @@ static int unpack_long (grib_accessor* a, long* v, size_t *len){
*v = strtol(val,&last,10);
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG, " Casting string %s to long", a->name);
grib_context_log(a->context,GRIB_LOG_DEBUG, " Casting string %s to long", a->name);
return GRIB_SUCCESS;
}
@ -262,7 +262,7 @@ static int unpack_double (grib_accessor* a, double*v, size_t *len){
if(*last == 0)
{
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG, " Casting string %s to long", a->name);
grib_context_log(a->context,GRIB_LOG_DEBUG, " Casting string %s to long", a->name);
return GRIB_SUCCESS;
}
@ -290,7 +290,7 @@ static int compare(grib_accessor* a,grib_accessor* b) {
if (alen != blen) return GRIB_COUNT_MISMATCH;
aval=(char*)grib_context_malloc(a->parent->h->context,alen*sizeof(char));
aval=(char*)grib_context_malloc(a->context,alen*sizeof(char));
bval=(char*)grib_context_malloc(b->parent->h->context,blen*sizeof(char));
grib_unpack_string(a,aval,&alen);
@ -299,7 +299,7 @@ static int compare(grib_accessor* a,grib_accessor* b) {
retval = GRIB_SUCCESS;
if (strcmp(aval,bval)) retval = GRIB_STRING_VALUE_MISMATCH;
grib_context_free(a->parent->h->context,aval);
grib_context_free(a->context,aval);
grib_context_free(b->parent->h->context,bval);
return retval;

View File

@ -162,7 +162,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
grib_accessor_hash_array* self=(grib_accessor_hash_array*)a;
char s[200]={0,};
sprintf(s,"%g",*val);
self->key=grib_context_strdup(a->parent->h->context,s);
self->key=grib_context_strdup(a->context,s);
self->ha=0;
return GRIB_SUCCESS;
}
@ -172,15 +172,15 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
grib_accessor_hash_array* self=(grib_accessor_hash_array*)a;
char s[200]={0,};
sprintf(s,"%ld",*val);
if (self->key) grib_context_free(a->parent->h->context,self->key);
self->key=grib_context_strdup(a->parent->h->context,s);
if (self->key) grib_context_free(a->context,self->key);
self->key=grib_context_strdup(a->context,s);
self->ha=0;
return GRIB_SUCCESS;
}
static int pack_string(grib_accessor*a , const char* v, size_t *len){
grib_accessor_hash_array* self=(grib_accessor_hash_array*)a;
self->key=grib_context_strdup(a->parent->h->context,v);
self->key=grib_context_strdup(a->context,v);
self->ha=0;
return GRIB_SUCCESS;
}
@ -201,7 +201,7 @@ static grib_hash_array_value* find_hash_value(grib_accessor* a,int *err) {
Assert(ha!=NULL);
if (!self->key) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"unable to get hash value for %s, set before getting",a->creator->name);
*err=GRIB_HASH_ARRAY_NO_MATCH;
return NULL;
@ -212,7 +212,7 @@ static grib_hash_array_value* find_hash_value(grib_accessor* a,int *err) {
if (!ha_ret) {
*err=GRIB_HASH_ARRAY_NO_MATCH;
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,
grib_context_log(a->context,GRIB_LOG_ERROR,
"hash_array: no match for %s=%s",
a->creator->name,self->key);
return NULL;

View File

@ -166,7 +166,7 @@ static int unpack_double (grib_accessor* a, double* val, size_t *len)
if(*len < rlen)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, " wrong size (%ld) for %s it contains %d values ", *len,a->name , rlen);
grib_context_log(a->context, GRIB_LOG_ERROR, " wrong size (%ld) for %s it contains %d values ", *len,a->name , rlen);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -190,7 +190,7 @@ static int pack_double (grib_accessor* a, const double* val, size_t *len)
if(*len < 1)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, " wrong size for %s it pack at least 1 values ", a->name , rlen );
grib_context_log(a->context, GRIB_LOG_ERROR, " wrong size for %s it pack at least 1 values ", a->name , rlen );
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -204,14 +204,14 @@ static int pack_double (grib_accessor* a, const double* val, size_t *len)
*/
off = byte_offset(a)*8;
ret = grib_encode_unsigned_long(a->parent->h->buffer->data,grib_ibm_to_long(val[0]), &off, 32);
if (*len > 1) grib_context_log(a->parent->h->context, GRIB_LOG_WARNING, "grib_accessor_unsigned : Trying to pack %d values in a scalar %s, packing first value", *len, a->name );
if (*len > 1) grib_context_log(a->context, GRIB_LOG_WARNING, "grib_accessor_unsigned : Trying to pack %d values in a scalar %s, packing first value", *len, a->name );
if (ret == GRIB_SUCCESS) len[0] = 1;
return ret;
}
buflen = rlen*4;
buf = (unsigned char*)grib_context_malloc(a->parent->h->context,buflen);
buf = (unsigned char*)grib_context_malloc(a->context,buflen);
for(i=0; i < rlen;i++){
grib_encode_unsigned_longb(buf,grib_ibm_to_long(val[i]), &off, 32);
@ -223,7 +223,7 @@ static int pack_double (grib_accessor* a, const double* val, size_t *len)
else
*len = 0;
grib_context_free(a->parent->h->context,buf);
grib_context_free(a->context,buf);
a->length = byte_count(a);
@ -261,7 +261,7 @@ static int nearest_smaller_value(grib_accessor* a, double val,double* nearest)
{
int ret=0;
if (grib_nearest_smaller_ibm_float(val,nearest)==GRIB_INTERNAL_ERROR) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"grib_nearest_smaller_ibm_float overflow value=%g\n",val);
grib_context_log(a->context,GRIB_LOG_ERROR,"grib_nearest_smaller_ibm_float overflow value=%g\n",val);
grib_dump_content(a->parent->h,stderr,"wmo",GRIB_DUMP_FLAG_HEXADECIMAL,0);
ret=GRIB_INTERNAL_ERROR;
}

View File

@ -165,7 +165,7 @@ static int pack_double (grib_accessor* a, const double* val, size_t *len)
if(*len < 1)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, " wrong size for %s it pack at least 1 values ", a->name , rlen );
grib_context_log(a->context, GRIB_LOG_ERROR, " wrong size for %s it pack at least 1 values ", a->name , rlen );
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -173,14 +173,14 @@ static int pack_double (grib_accessor* a, const double* val, size_t *len)
if (rlen == 1){
off = a->offset*8;
ret = grib_encode_unsigned_long(a->parent->h->buffer->data,grib_ieee_to_long(val[0]), &off, 32);
if (*len > 1) grib_context_log(a->parent->h->context, GRIB_LOG_WARNING, "grib_accessor_unsigned : Trying to pack %d values in a scalar %s, packing first value", *len, a->name );
if (*len > 1) grib_context_log(a->context, GRIB_LOG_WARNING, "grib_accessor_unsigned : Trying to pack %d values in a scalar %s, packing first value", *len, a->name );
if (ret == GRIB_SUCCESS) len[0] = 1;
return ret;
}
buflen = rlen*4;
buf = (unsigned char*)grib_context_malloc(a->parent->h->context,buflen);
buf = (unsigned char*)grib_context_malloc(a->context,buflen);
for(i=0; i < rlen;i++){
grib_encode_unsigned_longb(buf,grib_ieee_to_long(val[i]), &off, 32);
@ -192,7 +192,7 @@ static int pack_double (grib_accessor* a, const double* val, size_t *len)
else
*len = 0;
grib_context_free(a->parent->h->context,buf);
grib_context_free(a->context,buf);
return ret;
}
@ -209,7 +209,7 @@ static int unpack_double (grib_accessor* a, double* val, size_t *len)
if(*len < rlen)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, " wrong size (%ld) for %s it contains %d values ", *len,a->name , rlen);
grib_context_log(a->context, GRIB_LOG_ERROR, " wrong size (%ld) for %s it contains %d values ", *len,a->name , rlen);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -135,7 +135,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
if(*len < 1)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -135,7 +135,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
if(*len < 1)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -135,7 +135,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
if(*len < 1)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -135,7 +135,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
if(*len < 1)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -137,7 +137,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
if(*len < 1)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -152,7 +152,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
/* Result does not fit in long */
if(tmp != result) {
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Value for %s cannot be decoded as a 'long' (%llu)", a->name , result );
grib_context_log(a->context, GRIB_LOG_ERROR, "Value for %s cannot be decoded as a 'long' (%llu)", a->name , result );
return GRIB_DECODING_ERROR;
}

View File

@ -137,7 +137,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
if(*len < 1)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -152,7 +152,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
/* Result does not fit in long */
if(tmp != result) {
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Value for %s cannot be decoded as a 'long' (%llu)", a->name , result );
grib_context_log(a->context, GRIB_LOG_ERROR, "Value for %s cannot be decoded as a 'long' (%llu)", a->name , result );
return GRIB_DECODING_ERROR;
}

View File

@ -135,7 +135,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
if(*len < 1)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -149,7 +149,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
if(*len < 1)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -183,12 +183,12 @@ static int pack_string(grib_accessor* a, const char* val, size_t *len)
{
int i = 0;
if (len[0] != 4 ) {
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong length for %s. It has to be 4",a->name);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong length for %s. It has to be 4",a->name);
return GRIB_INVALID_KEY_VALUE;
}
if(len[0] > (a->length)+1)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "pack_string: Wrong size (%d) for %s it contains %d values ", len[0], a->name , a->length+1 );
grib_context_log(a->context, GRIB_LOG_ERROR, "pack_string: Wrong size (%d) for %s it contains %d values ", len[0], a->name , a->length+1 );
len[0] = 0;
return GRIB_BUFFER_TOO_SMALL;
}

View File

@ -167,7 +167,7 @@ static int unpack_double (grib_accessor* a, double* val, size_t *len)
if(*len < 1){
ret = GRIB_ARRAY_TOO_SMALL;
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR,
grib_context_log(a->context, GRIB_LOG_ERROR,
"Accessor %s cannot gather value for %s and/or %s error %d",
a->name,self->multiplier, self->divisor, ret);
return ret;
@ -213,24 +213,24 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
ret = grib_get_long_internal(a->parent->h, self->divisor,&divisor);
if(ret != GRIB_SUCCESS) {
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Accessor %s cannont gather value for %s error %d \n", a->name, self->divisor, ret);
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannont gather value for %s error %d \n", a->name, self->divisor, ret);
return ret;
}
ret = grib_get_long_internal(a->parent->h, self->multiplier,&multiplier);
if(ret != GRIB_SUCCESS){
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Accessor %s cannont gather value for %s error %d \n", a->name, self->divisor, ret);
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannont gather value for %s error %d \n", a->name, self->divisor, ret);
return ret;
}
if (self->truncating) {
ret = grib_get_long_internal(a->parent->h, self->truncating,&truncating);
if(ret != GRIB_SUCCESS){
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Accessor %s cannont gather value for %s error %d \n", a->name, self->truncating, ret);
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannont gather value for %s error %d \n", a->name, self->truncating, ret);
return ret;
}
}
if (multiplier == 0) {
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Accessor %s cannont divide by a zero multiplier %s error %d \n", a->name, self->multiplier, ret);
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannont divide by a zero multiplier %s error %d \n", a->name, self->multiplier, ret);
return GRIB_ENCODING_ERROR;
}
@ -244,7 +244,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
ret = grib_set_long_internal(a->parent->h, self->value,value);
if(ret )
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Accessor %s cannont pack value for %s error %d \n", a->name, self->value, ret);
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannont pack value for %s error %d \n", a->name, self->value, ret);
if (ret == GRIB_SUCCESS) *len = 1;
@ -263,7 +263,7 @@ static int is_missing(grib_accessor* a){
if((ret = grib_get_long_internal(a->parent->h,self->value,
&value) ) != GRIB_SUCCESS){
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR,
grib_context_log(a->context, GRIB_LOG_ERROR,
"Accessor %s cannont gather value for %s error %d \n", a->name,
self->value, ret);
return 0;

View File

@ -175,7 +175,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)
{
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
grib_accessor_latitudes* self = (grib_accessor_latitudes*)a;
int ret = 0;
double* v=val;
@ -229,7 +229,7 @@ static int value_count(grib_accessor* a,long* len)
{
grib_accessor_latitudes* self = (grib_accessor_latitudes*)a;
grib_handle* h=a->parent->h;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
double* val=NULL;
int ret;
size_t size;
@ -265,7 +265,7 @@ static int get_distinct(grib_accessor* a,double** val,long* len) {
int i;
long jScansPositively=0; /*default: north to south*/
size_t size=*len;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
grib_iterator* iter=grib_iterator_new(a->parent->h,0,&ret);
if (ret!=GRIB_SUCCESS) {
if (iter) grib_iterator_delete(iter);

View File

@ -311,7 +311,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
/*ret = grib_set_long_internal(a->parent->h, self->numberOfPoints,numberOfPoints);
if(ret )
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Accessor %s cannot pack value for %s error %d \n", a->name, self->numberOfPoints, ret);
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannot pack value for %s error %d \n", a->name, self->numberOfPoints, ret);
*/
grib_get_long_internal(a->parent->h, self->numberOfPoints,&codedNumberOfPoints);

View File

@ -148,7 +148,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)
{
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
int ret = 0;
double* v=val;
double lat,lon,value;

View File

@ -289,7 +289,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
break;
default:
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"Invalid localDefinitionNumber %d",localDefinitionNumber);
grib_context_log(a->context,GRIB_LOG_ERROR,"Invalid localDefinitionNumber %d",localDefinitionNumber);
return GRIB_ENCODING_ERROR;
break;
}

View File

@ -158,12 +158,12 @@ static int unpack_string(grib_accessor*a , char* v, size_t *len){
l = strlen(repres)+1;
if(l >*len ){
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "grib_accessor_long : unpack_string : Buffer too small for %s ", a->name );
grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_long : unpack_string : Buffer too small for %s ", a->name );
*len = l;
return GRIB_BUFFER_TOO_SMALL;
}
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG, "grib_accessor_long: Casting long %s to string ", a->name);
grib_context_log(a->context,GRIB_LOG_DEBUG, "grib_accessor_long: Casting long %s to string ", a->name);
*len = l;
@ -215,7 +215,7 @@ static int unpack_double(grib_accessor* a, double* val,size_t *len){
if(*len < rlen)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, " wrong size for %s it contains %d values ", a->name , rlen);
grib_context_log(a->context, GRIB_LOG_ERROR, " wrong size for %s it contains %d values ", a->name , rlen);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -228,19 +228,19 @@ static int unpack_double(grib_accessor* a, double* val,size_t *len){
return GRIB_SUCCESS;
}
values = (long*)grib_context_malloc(a->parent->h->context,rlen*sizeof(long));
values = (long*)grib_context_malloc(a->context,rlen*sizeof(long));
if(!values) return GRIB_INTERNAL_ERROR;
ret = grib_unpack_long(a,values,&rlen);
if(ret != GRIB_SUCCESS){
grib_context_free(a->parent->h->context,values);
grib_context_free(a->context,values);
return ret;
}
for(i=0; i< rlen;i++)
val[i] = values[i];
grib_context_free(a->parent->h->context,values);
grib_context_free(a->context,values);
*len = rlen;
return GRIB_SUCCESS;
@ -266,7 +266,7 @@ static int compare(grib_accessor* a,grib_accessor* b) {
if (alen != blen) return GRIB_COUNT_MISMATCH;
aval=(long*)grib_context_malloc(a->parent->h->context,alen*sizeof(long));
aval=(long*)grib_context_malloc(a->context,alen*sizeof(long));
bval=(long*)grib_context_malloc(b->parent->h->context,blen*sizeof(long));
grib_unpack_long(a,aval,&alen);
@ -278,7 +278,7 @@ static int compare(grib_accessor* a,grib_accessor* b) {
alen--;
}
grib_context_free(a->parent->h->context,aval);
grib_context_free(a->context,aval);
grib_context_free(b->parent->h->context,bval);
return retval;
@ -289,7 +289,7 @@ static int pack_string(grib_accessor* a, const char* val, size_t *len)
char* theEnd=NULL;
long v=strtol(val,&theEnd,10);
if (theEnd) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"trying to pack \"%s\" as long",val);
grib_context_log(a->context,GRIB_LOG_ERROR,"trying to pack \"%s\" as long",val);
return GRIB_WRONG_TYPE;
}
return grib_pack_long( a,&v,len);

View File

@ -182,9 +182,9 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len) {
/*TODO implement the dirty mechanism to avoid to unpack every time */
grib_get_size(a->parent->h,self->vector,&size);
vector=(long*)grib_context_malloc(a->parent->h->context,sizeof(long)*size);
vector=(long*)grib_context_malloc(a->context,sizeof(long)*size);
grib_unpack_long(va,vector,&size);
grib_context_free(a->parent->h->context,vector);
grib_context_free(a->context,vector);
*val = v->v[self->index];

View File

@ -163,7 +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)
{
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
grib_accessor_longitudes* self = (grib_accessor_longitudes*)a;
int ret = 0;
double* v=val;
@ -218,7 +218,7 @@ static int value_count(grib_accessor* a,long* len)
{
grib_accessor_longitudes* self = (grib_accessor_longitudes*)a;
grib_handle* h=a->parent->h;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
double* val=NULL;
int ret;
size_t size;
@ -252,7 +252,7 @@ static int get_distinct(grib_accessor* a,double** val,long* len) {
int ret=0;
int i;
size_t size=*len;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
grib_iterator* iter=grib_iterator_new(a->parent->h,0,&ret);
if (ret!=GRIB_SUCCESS) {
if (iter) grib_iterator_delete(iter);

View File

@ -218,7 +218,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
if(len[0] < 1)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
len[0] = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -152,7 +152,7 @@ static int pack_string(grib_accessor* a, const char* val, size_t *len)
grib_accessor* stepRangeAcc=grib_find_accessor(a->parent->h,self->stepRange);
if (!stepRangeAcc) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"%s not found",self->stepRange);
grib_context_log(a->context,GRIB_LOG_ERROR,"%s not found",self->stepRange);
return GRIB_NOT_FOUND;
}
@ -176,7 +176,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t *len)
grib_accessor* stepRangeAcc=grib_find_accessor(a->parent->h,self->stepRange);
if (!stepRangeAcc) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"%s not found",self->stepRange);
grib_context_log(a->context,GRIB_LOG_ERROR,"%s not found",self->stepRange);
return GRIB_NOT_FOUND;
}
@ -184,7 +184,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t *len)
return ret;
if (*len < buflen) {
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR,
grib_context_log(a->context, GRIB_LOG_ERROR,
"grib_accessor_class_mars_step: Buffer too small for %s. It is %ld bytes long (len=%ld)\n",
a->name, buflen, *len);
*len = buflen;

View File

@ -140,7 +140,7 @@ static void init(grib_accessor* a, const long len , grib_arguments* arg )
char* b=0;
int n=0;
grib_string_list* current=0;
grib_context* context=a->parent->h->context;
grib_context* context=a->context;
self->offset = grib_arguments_get_name(a->parent->h,arg,n++);
self->length = grib_arguments_get_expression(a->parent->h,arg,n++);
@ -201,7 +201,7 @@ static int unpack_string(grib_accessor*a , char* v, size_t *len){
struct grib_md5_state md5c;
if (*len <32 ) {
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR,"md5: array too small");
grib_context_log(a->context,GRIB_LOG_ERROR,"md5: array too small");
return GRIB_ARRAY_TOO_SMALL;
}
@ -212,11 +212,11 @@ static int unpack_string(grib_accessor*a , char* v, size_t *len){
!= GRIB_SUCCESS)
return ret;
mess=(unsigned char*)grib_context_malloc(a->parent->h->context,length);
mess=(unsigned char*)grib_context_malloc(a->context,length);
memcpy(mess,a->parent->h->buffer->data+offset,length);
mess_len=length;
blacklist=a->parent->h->context->blacklist;
blacklist=a->context->blacklist;
/* passed blacklist overrides context blacklist.
Consider to modify following line to extend context blacklist.
*/
@ -224,7 +224,7 @@ static int unpack_string(grib_accessor*a , char* v, size_t *len){
while (blacklist && blacklist->value) {
b=grib_find_accessor(a->parent->h,blacklist->value);
if (!b) {
grib_context_free(a->parent->h->context,mess);
grib_context_free(a->context,mess);
return GRIB_NOT_FOUND;
}
@ -237,7 +237,7 @@ static int unpack_string(grib_accessor*a , char* v, size_t *len){
grib_md5_init(&md5c);
grib_md5_add(&md5c,mess,mess_len);
grib_md5_end(&md5c,v);
grib_context_free(a->parent->h->context,mess);
grib_context_free(a->context,mess);
return ret;
}

View File

@ -155,11 +155,11 @@ static void update_size(grib_accessor* a,size_t new_size)
static void resize(grib_accessor* a,size_t new_size)
{
void* zero = grib_context_malloc_clear(a->parent->h->context,new_size);
void* zero = grib_context_malloc_clear(a->context,new_size);
grib_buffer_replace(a,(const unsigned char*)zero,new_size,1,0);
grib_context_free(a->parent->h->context,zero);
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG,"resize: grib_accessor_class_message.c %ld %ld %s %s\n",(long)new_size,(long)a->length,a->cclass->name,a->name);
grib_context_free(a->context,zero);
grib_context_log(a->context,GRIB_LOG_DEBUG,"resize: grib_accessor_class_message.c %ld %ld %s %s\n",(long)new_size,(long)a->length,a->cclass->name,a->name);
Assert(new_size == a->length);
}
@ -173,7 +173,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t *len)
if(len[0] < (a->length+1))
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%d) for %s it contains %d values ", len[0], a->name , a->length+1 );
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%d) for %s it contains %d values ", len[0], a->name , a->length+1 );
len[0] = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -179,7 +179,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t *len)
if(len[0] < (a->length+1))
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%d) for %s it contains %d values ", len[0], a->name , a->length+1 );
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%d) for %s it contains %d values ", len[0], a->name , a->length+1 );
len[0] = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -198,12 +198,12 @@ static int pack_string(grib_accessor* a, const char* val, size_t *len)
}
static int pack_long(grib_accessor* a, const long* v, size_t *len){
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR, " Should not pack %s as long", a->name);
grib_context_log(a->context,GRIB_LOG_ERROR, " Should not pack %s as long", a->name);
return GRIB_NOT_IMPLEMENTED;
}
static int pack_double(grib_accessor* a, const double*v, size_t *len){
grib_context_log(a->parent->h->context,GRIB_LOG_ERROR, " Should not pack %s as double", a->name);
grib_context_log(a->context,GRIB_LOG_ERROR, " Should not pack %s as double", a->name);
return GRIB_NOT_IMPLEMENTED;
}
@ -229,7 +229,7 @@ static int unpack_long (grib_accessor* a, long* v, size_t *len){
*v = strtol(val,&last,10);
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG, " Casting string %s to long", a->name);
grib_context_log(a->context,GRIB_LOG_DEBUG, " Casting string %s to long", a->name);
return GRIB_SUCCESS;
}
@ -244,7 +244,7 @@ static int unpack_double (grib_accessor* a, double*v, size_t *len){
if(*last == 0)
{
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG, " Casting string %s to long", a->name);
grib_context_log(a->context,GRIB_LOG_DEBUG, " Casting string %s to long", a->name);
return GRIB_SUCCESS;
}
@ -273,7 +273,7 @@ static int compare(grib_accessor* a,grib_accessor* b)
if (alen != blen) return GRIB_COUNT_MISMATCH;
aval=(char*)grib_context_malloc(a->parent->h->context,alen*sizeof(char));
aval=(char*)grib_context_malloc(a->context,alen*sizeof(char));
bval=(char*)grib_context_malloc(b->parent->h->context,blen*sizeof(char));
grib_unpack_string(a,aval,&alen);
@ -282,7 +282,7 @@ static int compare(grib_accessor* a,grib_accessor* b)
retval = GRIB_SUCCESS;
if (strcmp(aval,bval)) retval = GRIB_STRING_VALUE_MISMATCH;
grib_context_free(a->parent->h->context,aval);
grib_context_free(a->context,aval);
grib_context_free(b->parent->h->context,bval);
return retval;

View File

@ -177,7 +177,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
return ret;
if ( bpv != 0 ) {
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG,"grib_accessor_number_of_coded_values: offsetAfterData=%ld offsetBeforeData=%ld unusedBits=%ld bpv=%ld\n",
grib_context_log(a->context,GRIB_LOG_DEBUG,"grib_accessor_number_of_coded_values: offsetAfterData=%ld offsetBeforeData=%ld unusedBits=%ld bpv=%ld\n",
offsetAfterData,offsetBeforeData,unusedBits,bpv);
*val=((offsetAfterData-offsetBeforeData)*8-unusedBits)/bpv;
} else {

View File

@ -160,7 +160,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
long* pl;
int i;
grib_accessor_number_of_points* self = (grib_accessor_number_of_points*)a;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
if((ret = grib_get_long_internal(a->parent->h, self->ni,&ni)) != GRIB_SUCCESS)
return ret;

View File

@ -184,7 +184,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
long ilon_first=0,ilon_last=0;
grib_accessor_number_of_points_gaussian* self = (grib_accessor_number_of_points_gaussian*)a;
grib_context* c=a->parent->h->context;
grib_context* c=a->context;
if((ret = grib_get_long_internal(a->parent->h, self->ni,&ni)) != GRIB_SUCCESS)
return ret;
@ -215,7 +215,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
if((ret = grib_get_double_internal(a->parent->h, self->lon_last,&lon_last)) != GRIB_SUCCESS)
return ret;
lats=(double*)grib_context_malloc(a->parent->h->context,sizeof(double)*order*2);
lats=(double*)grib_context_malloc(a->context,sizeof(double)*order*2);
if((ret = grib_get_gaussian_latitudes(order, lats)) != GRIB_SUCCESS)
return ret;

Some files were not shown because too many files have changed in this diff Show More