diff --git a/src/grib_accessor_class.c b/src/grib_accessor_class.c index 89c819cff..310299cb9 100644 --- a/src/grib_accessor_class.c +++ b/src/grib_accessor_class.c @@ -32,19 +32,19 @@ static void init() { struct table_entry { - char *type; - grib_accessor_class **cclass; + char *type; + grib_accessor_class **cclass; }; static GRIB_INLINE int grib_inline_strcmp(const char* a,const char* b) { - if (*a != *b) return 1; - while((*a!=0 && *b!=0) && *(a) == *(b) ) {a++;b++;} - return (*a==0 && *b==0) ? 0 : 1; + if (*a != *b) return 1; + while((*a!=0 && *b!=0) && *(a) == *(b) ) {a++;b++;} + return (*a==0 && *b==0) ? 0 : 1; } static struct table_entry table[] = { - /* This file is generated my ./make_class.pl */ +/* This file is generated my ./make_class.pl */ #include "grib_accessor_factory.h" }; @@ -52,318 +52,315 @@ static struct table_entry table[] = grib_section* grib_create_root_section(const grib_context *context, grib_handle *h) { - char* fpath=0; - grib_section* s = (grib_section*) grib_context_malloc_clear(context,sizeof(grib_section)); + char* fpath=0; + grib_section* s = (grib_section*) grib_context_malloc_clear(context,sizeof(grib_section)); - GRIB_PTHREAD_ONCE(&once,&init); - GRIB_MUTEX_LOCK(&mutex1); - if(h->context->grib_reader == NULL) { - if ((fpath=grib_context_full_defs_path(h->context,"boot.def"))==NULL) { - grib_context_log(h->context,GRIB_LOG_FATAL, - "Unable to find boot.def "); + GRIB_PTHREAD_ONCE(&once,&init); + GRIB_MUTEX_LOCK(&mutex1); + if(h->context->grib_reader == NULL) { + if ((fpath=grib_context_full_defs_path(h->context,"boot.def"))==NULL) { + grib_context_log(h->context,GRIB_LOG_FATAL, + "Unable to find boot.def. Context path=%s", context->grib_definition_files_path); + } + grib_parse_file(h->context,fpath); } - grib_parse_file(h->context,fpath); - } - GRIB_MUTEX_UNLOCK(&mutex1); + GRIB_MUTEX_UNLOCK(&mutex1); - s->h = h; - s->aclength = NULL; - s->owner = NULL; - s->block = (grib_block_of_accessors*) - grib_context_malloc_clear(context, sizeof(grib_block_of_accessors)); - grib_context_log(context, GRIB_LOG_DEBUG, "Creating root section"); - return s; + s->h = h; + s->aclength = NULL; + s->owner = NULL; + s->block = (grib_block_of_accessors*) + grib_context_malloc_clear(context, sizeof(grib_block_of_accessors)); + grib_context_log(context, GRIB_LOG_DEBUG, "Creating root section"); + return s; } static GRIB_INLINE grib_accessor_class* get_class(grib_context* c,char* type) { - int i; - grib_accessor_class** class=NULL; + int i; + grib_accessor_class** class=NULL; - if ( (class=grib_trie_get(c->classes,type))!=NULL) - return *(class); + if ( (class=grib_trie_get(c->classes,type))!=NULL) + return *(class); - for(i = 0; i < NUMBER(table) ; i++) { - if( grib_inline_strcmp(type,table[i].type) == 0 ) - { - grib_trie_insert(c->classes,type,table[i].cclass); - return *(table[i].cclass); - } - } - grib_context_log(c,GRIB_LOG_FATAL,"unable to create class %s",type); - return NULL; + for(i = 0; i < NUMBER(table) ; i++) { + if( grib_inline_strcmp(type,table[i].type) == 0 ) + { + grib_trie_insert(c->classes,type,table[i].cclass); + return *(table[i].cclass); + } + } + grib_context_log(c,GRIB_LOG_FATAL,"unable to create class %s",type); + return NULL; } grib_accessor* grib_accessor_factory(grib_section* p, grib_action* creator, - const long len, grib_arguments* params) + const long len, grib_arguments* params) { - grib_accessor_class* c=NULL; - grib_accessor* a=NULL; - size_t size=0; + grib_accessor_class* c=NULL; + grib_accessor* a=NULL; + size_t size=0; - c = get_class(p->h->context,creator->op); - /* c=*((grib_accessor_classes_hash(creator->op,strlen(creator->op)))->cclass); */ + c = get_class(p->h->context,creator->op); + /* c=*((grib_accessor_classes_hash(creator->op,strlen(creator->op)))->cclass); */ - a = (grib_accessor*) grib_context_malloc_clear(p->h->context,c->size); + a = (grib_accessor*) grib_context_malloc_clear(p->h->context,c->size); - a->name = creator->name; - a->name_space = creator->name_space; + a->name = creator->name; + a->name_space = creator->name_space; - a->all_names[0] = creator->name; - a->all_name_spaces[0] = creator->name_space; + a->all_names[0] = creator->name; + a->all_name_spaces[0] = creator->name_space; - a->creator = creator; - a->next = NULL; - a->previous = NULL; - a->parent = p; - a->length = 0 ; - a->offset = 0; - a->flags = creator->flags; - a->set = creator->set; + a->creator = creator; + a->next = NULL; + a->previous = NULL; + a->parent = p; + a->length = 0 ; + a->offset = 0; + a->flags = creator->flags; + a->set = creator->set; - if(p->block->last) { - a->offset = grib_get_next_position_offset(p->block->last); - #if 0 - printf("offset: p->block->last %s %s %ld %ld\n", - p->block->last->cclass->name, - p->block->last->name,(long)p->block->last->offset,(long)p->block->last->length); - #endif - } else { - if(p->owner) { - a->offset = p->owner->offset; - } else - a->offset = 0; - } + if(p->block->last) { + a->offset = grib_get_next_position_offset(p->block->last); +#if 0 + printf("offset: p->block->last %s %s %ld %ld\n", + p->block->last->cclass->name, + p->block->last->name,(long)p->block->last->offset,(long)p->block->last->length); +#endif + } else { + if(p->owner) { + a->offset = p->owner->offset; + } else + a->offset = 0; + } - a->cclass = c; + a->cclass = c; - grib_init_accessor(a, len, params); - size = grib_get_next_position_offset(a); + grib_init_accessor(a, len, params); + size = grib_get_next_position_offset(a); - if(size > p->h->buffer->ulength) { - if(!p->h->buffer->growable) { - if(!p->h->partial) - grib_context_log(p->h->context, GRIB_LOG_ERROR, - "Creating (%s)%s of %s at offset %d-%d over message boundary (%d)", - p->owner?p->owner->name : "" ,a->name , - creator->op, a->offset, - a->offset + a->length, - p->h->buffer->ulength); + if(size > p->h->buffer->ulength) { + if(!p->h->buffer->growable) { + if(!p->h->partial) + grib_context_log(p->h->context, GRIB_LOG_ERROR, + "Creating (%s)%s of %s at offset %d-%d over message boundary (%d)", + p->owner?p->owner->name : "" ,a->name , + creator->op, a->offset, + a->offset + a->length, + p->h->buffer->ulength); - grib_free_accessor(p->h->context,a); - return NULL; - } else { - grib_context_log(p->h->context,GRIB_LOG_DEBUG, - "CREATE: name=%s class=%s offset=%ld length=%ld action=", - a->name,a->cclass->name,a->offset,a->length); + grib_free_accessor(p->h->context,a); + return NULL; + } else { + grib_context_log(p->h->context,GRIB_LOG_DEBUG, + "CREATE: name=%s class=%s offset=%ld length=%ld action=", + a->name,a->cclass->name,a->offset,a->length); - grib_grow_buffer(p->h->context,p->h->buffer,size); - p->h->buffer->ulength = size; - } - } + grib_grow_buffer(p->h->context,p->h->buffer,size); + p->h->buffer->ulength = size; + } + } + if(p->owner) + grib_context_log(p->h->context, GRIB_LOG_DEBUG, + "Creating (%s)%s of %s at offset %d [len=%d]", + p->owner->name ,a->name ,creator->op, a->offset,len,p->block); + else + grib_context_log(p->h->context, GRIB_LOG_DEBUG, + "Creating root %s of %s at offset %d [len=%d]", + a->name ,creator->op, a->offset,len,p->block); - if(p->owner) - grib_context_log(p->h->context, GRIB_LOG_DEBUG, - "Creating (%s)%s of %s at offset %d [len=%d]", - p->owner->name ,a->name ,creator->op, a->offset,len,p->block); - else - grib_context_log(p->h->context, GRIB_LOG_DEBUG, - "Creating root %s of %s at offset %d [len=%d]", - a->name ,creator->op, a->offset,len,p->block); - - return a; + return a; } void grib_push_accessor(grib_accessor* a, grib_block_of_accessors* l) { - int id; - if (!l->first) - l->first = l->last = a; - else{ - l->last->next = a; - a->previous = l->last; - } - l->last = a; - - - 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]); - - - a->same=a->parent->h->accessors[id]; - a->parent->h->accessors[id]=a; - - if(a->same == a) { - fprintf(stderr,"---> %s\n",a->name); - Assert(a->same != a); - } + int id; + if (!l->first) + l->first = l->last = a; + else{ + l->last->next = a; + a->previous = l->last; } - } + l->last = a; + + 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]); + + + a->same=a->parent->h->accessors[id]; + a->parent->h->accessors[id]=a; + + if(a->same == a) { + fprintf(stderr,"---> %s\n",a->name); + Assert(a->same != a); + } + } + } } void grib_section_post_init(grib_section* s) { - grib_accessor* a = s ? s->block->first : NULL; + grib_accessor* a = s ? s->block->first : NULL; - while(a ) { - grib_accessor_class* c=a->cclass; - if(c->post_init) c->post_init(a); - if (a->sub_section) - grib_section_post_init(a->sub_section); - a = a->next; - } + while(a ) { + grib_accessor_class* c=a->cclass; + if(c->post_init) c->post_init(a); + if (a->sub_section) + grib_section_post_init(a->sub_section); + a = a->next; + } } void grib_section_adjust_sizes(grib_section* s,int update,int depth) { - grib_accessor* a = s ? s->block->first : NULL; - size_t length = update ? 0 : (s?s->padding:0); - size_t offset = (s && s->owner) ? s->owner->offset:0; - int force_update = update > 1; + grib_accessor* a = s ? s->block->first : NULL; + size_t length = update ? 0 : (s?s->padding:0); + size_t offset = (s && s->owner) ? s->owner->offset:0; + int force_update = update > 1; - while(a) { - register long l; - /* grib_section_adjust_sizes(grib_get_sub_section(a),update,depth+1); */ - grib_section_adjust_sizes(a->sub_section,update,depth+1); + while(a) { + register long l; + /* grib_section_adjust_sizes(grib_get_sub_section(a),update,depth+1); */ + grib_section_adjust_sizes(a->sub_section,update,depth+1); - l = a->length; - - if(offset != a->offset) { - grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG,"Offset mismatch %s A->offset %ld offset %ld\n",a->name,(long)a->offset, (long)offset); - a->offset = offset; + l = a->length; + + if(offset != a->offset) { + grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG,"Offset mismatch %s A->offset %ld offset %ld\n",a->name,(long)a->offset, (long)offset); + a->offset = offset; + } + length += l; + offset += l; + a = a->next; } - length += l; - offset += l; - a = a->next; - } - if(s) - { - if(s->aclength) + if(s) { - size_t len = 1; - long plen = 0; - int lret=grib_unpack_long(s->aclength, &plen, &len); - Assert( lret == GRIB_SUCCESS); - /* This happens when there is some padding */ - if((plen != length) || force_update) - { - if(update) + if(s->aclength) { - plen = length; - lret=grib_pack_long(s->aclength, &plen, &len); - Assert(lret == GRIB_SUCCESS); - s->padding = 0; - } - else { - if(!s->h->partial) { - if(length >= plen) + size_t len = 1; + long plen = 0; + int lret=grib_unpack_long(s->aclength, &plen, &len); + Assert( lret == GRIB_SUCCESS); + /* This happens when there is some padding */ + if((plen != length) || force_update) { - grib_context_log(s->h->context,GRIB_LOG_ERROR,"Invalid size %ld found for %s, assuming %ld", - (long)plen,s->owner->name,(long)length); - plen = length; + if(update) + { + plen = length; + lret=grib_pack_long(s->aclength, &plen, &len); + Assert(lret == GRIB_SUCCESS); + s->padding = 0; + } + else { + if(!s->h->partial) { + if(length >= plen) + { + grib_context_log(s->h->context,GRIB_LOG_ERROR,"Invalid size %ld found for %s, assuming %ld", + (long)plen,s->owner->name,(long)length); + plen = length; + } + s->padding = plen - length; + } + length = plen; + } } - s->padding = plen - length; - } - length = plen; } - } - } - if(s->owner) s->owner->length = length; - s->length = length; - } + if(s->owner) s->owner->length = length; + s->length = length; + } } int grib_get_block_length(grib_section* s, size_t *l) { - *l = s->length; - return GRIB_SUCCESS; + *l = s->length; + return GRIB_SUCCESS; #if 0 - /* TODO: Because grib_pack_long takes a SIGNED value, we may have problems */ + /* TODO: Because grib_pack_long takes a SIGNED value, we may have problems */ - if(s->aclength) - { - size_t len = 1; - long plen = 0; - - int ret = grib_unpack_long(s->aclength, &plen, &len); - if(ret == GRIB_SUCCESS && plen != 0) + if(s->aclength) { - *l = plen; - return GRIB_SUCCESS; + size_t len = 1; + long plen = 0; + + int ret = grib_unpack_long(s->aclength, &plen, &len); + if(ret == GRIB_SUCCESS && plen != 0) + { + *l = plen; + return GRIB_SUCCESS; + } } - } - /* empty block */ - if(s->block->first == NULL) - { - *l = 0; - return GRIB_SUCCESS; - } - /* no accessor for block length */ - if(s->owner) - *l = grib_get_next_position_offset(s->block->last) - s->owner->offset; - else - *l = grib_get_next_position_offset(s->block->last); + /* empty block */ + if(s->block->first == NULL) + { + *l = 0; + return GRIB_SUCCESS; + } + /* no accessor for block length */ + if(s->owner) + *l = grib_get_next_position_offset(s->block->last) - s->owner->offset; + else + *l = grib_get_next_position_offset(s->block->last); - if(s->aclength) - { - size_t len = 1; - long plen = *l; + if(s->aclength) + { + size_t len = 1; + long plen = *l; - int ret = grib_pack_long(s->aclength, &plen, &len); - if(ret != GRIB_SUCCESS) - ; - if(s->h->context->debug) - printf("SECTION updating length %ld %s\n",plen,s->owner->name); - } + int ret = grib_pack_long(s->aclength, &plen, &len); + if(ret != GRIB_SUCCESS) + ; + if(s->h->context->debug) + printf("SECTION updating length %ld %s\n",plen,s->owner->name); + } - /* + /* if(s->aclength) Assert(*l == plen);*/ - return GRIB_SUCCESS; + return GRIB_SUCCESS; #endif } - grib_accessor* find_paddings(grib_section* s) { - grib_accessor* a = s ? s->block->first : NULL; + grib_accessor* a = s ? s->block->first : NULL; - while(a) - { - /* grib_accessor* p = find_paddings(grib_get_sub_section(a)); */ - grib_accessor* p = find_paddings(a->sub_section); - if(p) return p; + while(a) + { + /* grib_accessor* p = find_paddings(grib_get_sub_section(a)); */ + grib_accessor* p = find_paddings(a->sub_section); + if(p) return p; - if(grib_preferred_size(a,0) != a->length) - return a; + if(grib_preferred_size(a,0) != a->length) + return a; - a = a->next; - } + a = a->next; + } - return NULL; + return NULL; } void grib_update_paddings(grib_section* s) { - grib_accessor* last = NULL; - grib_accessor* changed; + grib_accessor* last = NULL; + grib_accessor* changed; - /* while((changed = find_paddings(s)) != NULL) */ - while((changed = find_paddings(s->h->root)) != NULL) - { - Assert(changed != last); - grib_resize(changed,grib_preferred_size(changed,0)); - last = changed; - } + /* while((changed = find_paddings(s)) != NULL) */ + while((changed = find_paddings(s->h->root)) != NULL) + { + Assert(changed != last); + grib_resize(changed,grib_preferred_size(changed,0)); + last = changed; + } } diff --git a/src/grib_context.c b/src/grib_context.c index 1d1889fe8..9595c880e 100644 --- a/src/grib_context.c +++ b/src/grib_context.c @@ -281,90 +281,97 @@ static grib_context default_grib_context = { }; -grib_context* grib_context_get_default(){ - GRIB_PTHREAD_ONCE(&once,&init); +grib_context* grib_context_get_default() +{ + GRIB_PTHREAD_ONCE(&once,&init); - if(!default_grib_context.inited) - { - const char * write_on_fail = NULL; - const char * large_constant_fields = NULL; - const char * no_abort = NULL; - const char * debug = NULL; - const char *gribex=NULL; - const char *ieee_packing=NULL; - const char *io_buffer_size=NULL; - const char *log_stream=NULL; - const char *no_big_group_split=NULL; - const char *no_spd=NULL; - const char *keep_matrix=NULL; + if(!default_grib_context.inited) + { + const char * write_on_fail = NULL; + const char * large_constant_fields = NULL; + const char * no_abort = NULL; + const char * debug = NULL; + const char *gribex=NULL; + const char *ieee_packing=NULL; + const char *io_buffer_size=NULL; + const char *log_stream=NULL; + const char *no_big_group_split=NULL; + const char *no_spd=NULL; + const char *keep_matrix=NULL; - GRIB_MUTEX_LOCK(&mutex_c); + GRIB_MUTEX_LOCK(&mutex_c); - write_on_fail = getenv("GRIB_API_WRITE_ON_FAIL"); - large_constant_fields = getenv("GRIB_API_LARGE_CONSTANT_FIELDS"); - no_abort = getenv("GRIB_API_NO_ABORT"); - debug = getenv("GRIB_API_DEBUG"); - gribex=getenv("GRIB_GRIBEX_MODE_ON"); - ieee_packing=getenv("GRIB_IEEE_PACKING"); - io_buffer_size=getenv("GRIB_API_IO_BUFFER_SIZE"); - log_stream=getenv("GRIB_API_LOG_STREAM"); - no_big_group_split=getenv("GRIB_API_NO_BIG_GROUP_SPLIT"); - no_spd=getenv("GRIB_API_NO_SPD"); - keep_matrix=getenv("GRIB_API_KEEP_MATRIX"); + write_on_fail = getenv("GRIB_API_WRITE_ON_FAIL"); + large_constant_fields = getenv("GRIB_API_LARGE_CONSTANT_FIELDS"); + no_abort = getenv("GRIB_API_NO_ABORT"); + debug = getenv("GRIB_API_DEBUG"); + gribex=getenv("GRIB_GRIBEX_MODE_ON"); + ieee_packing=getenv("GRIB_IEEE_PACKING"); + io_buffer_size=getenv("GRIB_API_IO_BUFFER_SIZE"); + log_stream=getenv("GRIB_API_LOG_STREAM"); + no_big_group_split=getenv("GRIB_API_NO_BIG_GROUP_SPLIT"); + no_spd=getenv("GRIB_API_NO_SPD"); + keep_matrix=getenv("GRIB_API_KEEP_MATRIX"); - /* On UNIX, when we read from a file we get exactly what is in the file on disk. - * But on Windows a file can be opened in binary or text mode. In binary mode the system behaves exactly as in UNIX. - */ + /* On UNIX, when we read from a file we get exactly what is in the file on disk. + * But on Windows a file can be opened in binary or text mode. In binary mode the system behaves exactly as in UNIX. + */ #ifdef GRIB_ON_WINDOWS - _set_fmode(_O_BINARY); + _set_fmode(_O_BINARY); #endif - default_grib_context.inited = 1; - default_grib_context.io_buffer_size = io_buffer_size ? atoi(io_buffer_size) : 0; - default_grib_context.no_big_group_split = no_big_group_split ? atoi(no_big_group_split) : 0; - default_grib_context.no_spd = no_spd ? atoi(no_spd) : 0; - default_grib_context.keep_matrix = keep_matrix ? atoi(keep_matrix) : 1; - default_grib_context.write_on_fail = write_on_fail ? atoi(write_on_fail) : 0; - default_grib_context.no_abort = no_abort ? atoi(no_abort) : 0; - default_grib_context.debug = debug ? atoi(debug) : 0; - default_grib_context.gribex_mode_on=gribex ? atoi(gribex) : 0; - default_grib_context.large_constant_fields = large_constant_fields ? atoi(large_constant_fields) : 0; - default_grib_context.ieee_packing=ieee_packing ? atoi(ieee_packing) : 0; - default_grib_context.grib_samples_path = getenv("GRIB_SAMPLES_PATH"); - default_grib_context.log_stream=stderr; - if (!log_stream) { - default_grib_context.log_stream=stderr; - } else if (!strcmp(log_stream,"stderr") ) { - default_grib_context.log_stream=stderr; - } else if (!strcmp(log_stream,"stdout") ) { - default_grib_context.log_stream=stdout; - } + default_grib_context.inited = 1; + default_grib_context.io_buffer_size = io_buffer_size ? atoi(io_buffer_size) : 0; + default_grib_context.no_big_group_split = no_big_group_split ? atoi(no_big_group_split) : 0; + default_grib_context.no_spd = no_spd ? atoi(no_spd) : 0; + default_grib_context.keep_matrix = keep_matrix ? atoi(keep_matrix) : 1; + default_grib_context.write_on_fail = write_on_fail ? atoi(write_on_fail) : 0; + default_grib_context.no_abort = no_abort ? atoi(no_abort) : 0; + default_grib_context.debug = debug ? atoi(debug) : 0; + default_grib_context.gribex_mode_on=gribex ? atoi(gribex) : 0; + default_grib_context.large_constant_fields = large_constant_fields ? atoi(large_constant_fields) : 0; + default_grib_context.ieee_packing=ieee_packing ? atoi(ieee_packing) : 0; + default_grib_context.grib_samples_path = getenv("GRIB_SAMPLES_PATH"); + default_grib_context.log_stream=stderr; + if (!log_stream) { + default_grib_context.log_stream=stderr; + } else if (!strcmp(log_stream,"stderr") ) { + default_grib_context.log_stream=stderr; + } else if (!strcmp(log_stream,"stdout") ) { + default_grib_context.log_stream=stdout; + } - if (!default_grib_context.grib_samples_path) - default_grib_context.grib_samples_path = getenv("GRIB_TEMPLATES_PATH"); + if (!default_grib_context.grib_samples_path) + default_grib_context.grib_samples_path = getenv("GRIB_TEMPLATES_PATH"); #ifdef GRIB_TEMPLATES_PATH - if(!default_grib_context.grib_samples_path) - default_grib_context.grib_samples_path = GRIB_TEMPLATES_PATH ; + if(!default_grib_context.grib_samples_path) + default_grib_context.grib_samples_path = GRIB_TEMPLATES_PATH ; #endif - default_grib_context.grib_definition_files_path = getenv("GRIB_DEFINITION_PATH"); + + default_grib_context.grib_definition_files_path = getenv("GRIB_DEFINITION_PATH"); #ifdef GRIB_DEFINITION_PATH - if(!default_grib_context.grib_definition_files_path) - default_grib_context.grib_definition_files_path = GRIB_DEFINITION_PATH ; + if(!default_grib_context.grib_definition_files_path) + default_grib_context.grib_definition_files_path = GRIB_DEFINITION_PATH ; #endif - default_grib_context.keys_count=0; - default_grib_context.keys=grib_hash_keys_new(&(default_grib_context), - &(default_grib_context.keys_count)); - default_grib_context.concepts_index=grib_itrie_new(&(default_grib_context), - &(default_grib_context.concepts_count)); - default_grib_context.def_files=grib_trie_new(&(default_grib_context)); - default_grib_context.classes=grib_trie_new(&(default_grib_context)); + grib_context_log(&default_grib_context, GRIB_LOG_DEBUG, "Definitions path: %s", + default_grib_context.grib_definition_files_path); + grib_context_log(&default_grib_context, GRIB_LOG_DEBUG, "Samples path: %s", + default_grib_context.grib_samples_path); - GRIB_MUTEX_UNLOCK(&mutex_c); - } + default_grib_context.keys_count=0; + default_grib_context.keys=grib_hash_keys_new(&(default_grib_context), + &(default_grib_context.keys_count)); + default_grib_context.concepts_index=grib_itrie_new(&(default_grib_context), + &(default_grib_context.concepts_count)); + default_grib_context.def_files=grib_trie_new(&(default_grib_context)); + default_grib_context.classes=grib_trie_new(&(default_grib_context)); - return &default_grib_context; + GRIB_MUTEX_UNLOCK(&mutex_c); + } + + return &default_grib_context; } /* TODO: use parent */ @@ -534,7 +541,6 @@ char *grib_context_full_defs_path(grib_context* c,const char* basename) } dir=dir->next; } - } GRIB_MUTEX_LOCK(&mutex_c); diff --git a/src/grib_errors.c b/src/grib_errors.c index ce0bc1944..b335f8cb7 100644 --- a/src/grib_errors.c +++ b/src/grib_errors.c @@ -1,5 +1,15 @@ /* This file is automatically generated by ./errors.pl, do not edit */ +/* + * Copyright 2005-2013 ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + #include "grib_api_internal.h" static const char *errors[] = {