mirror of https://github.com/ecmwf/eccodes.git
ECC-163
This commit is contained in:
parent
b6c5c81427
commit
a74e2e1cf8
|
@ -669,6 +669,7 @@ 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;
|
||||
a->attributes[id]=attr;
|
||||
attr->parent_as_attribute=a;
|
||||
if (a->same)
|
||||
|
|
|
@ -1180,7 +1180,7 @@ static grib_accessor* create_accessor_from_descriptor(grib_accessor* a,grib_acce
|
|||
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("code",section,GRIB_TYPE_STRING,grib_context_strdup(a->parent->h->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);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
IMPLEMENTS = init;dump
|
||||
IMPLEMENTS = unpack_string;unpack_string_array;unpack_long; unpack_double
|
||||
IMPLEMENTS = pack_long; pack_double ; pack_string_array; pack_string
|
||||
IMPLEMENTS = value_count; get_native_type; clone
|
||||
IMPLEMENTS = value_count; get_native_type; clone; destroy
|
||||
MEMBERS = long index
|
||||
MEMBERS = int type
|
||||
MEMBERS = long compressedData
|
||||
|
@ -62,6 +62,8 @@ static void dump(grib_accessor*, grib_dumper*);
|
|||
static void init(grib_accessor*,const long, grib_arguments* );
|
||||
static void init_class(grib_accessor_class*);
|
||||
static grib_accessor* clone(grib_accessor*,grib_section*,int*);
|
||||
static void destroy(grib_context*,grib_accessor*);
|
||||
|
||||
|
||||
typedef struct grib_accessor_bufr_data_element {
|
||||
grib_accessor att;
|
||||
|
@ -88,7 +90,7 @@ static grib_accessor_class _grib_accessor_class_bufr_data_element = {
|
|||
&init_class, /* init_class */
|
||||
&init, /* init */
|
||||
0, /* post_init */
|
||||
0, /* free mem */
|
||||
&destroy, /* free mem */
|
||||
&dump, /* describes himself */
|
||||
0, /* get length of section */
|
||||
0, /* get length of string */
|
||||
|
@ -543,4 +545,13 @@ static int get_native_type(grib_accessor* a){
|
|||
}
|
||||
|
||||
|
||||
|
||||
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);
|
||||
grib_accessor_delete(ct,a->attributes[i]);
|
||||
a->attributes[i]=NULL;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -484,20 +484,13 @@ static int pack_bytes(grib_accessor* a, const unsigned char* val, size_t *len)
|
|||
|
||||
static void destroy(grib_context* ct, grib_accessor* a)
|
||||
{
|
||||
int i=0;
|
||||
grib_dependency_remove_observed(a);
|
||||
grib_dependency_remove_observer(a);
|
||||
if (a->vvalue!=NULL) {
|
||||
grib_context_free(ct,a->vvalue);
|
||||
a->vvalue=NULL;
|
||||
}
|
||||
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG,"address=%p",a);
|
||||
while (i<MAX_ACCESSOR_ATTRIBUTES && a->attributes[i]) {
|
||||
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG,"deleting attribute %s->%s",a->name,a->attributes[i]->name);
|
||||
grib_accessor_delete(a->parent->h->context,a->attributes[i]);
|
||||
a->attributes[i]=NULL;
|
||||
i++;
|
||||
}
|
||||
grib_context_log(ct,GRIB_LOG_DEBUG,"address=%p",a);
|
||||
}
|
||||
|
||||
static grib_section* sub_section(grib_accessor* a)
|
||||
|
|
Loading…
Reference in New Issue