Fix compiler errors when using g++

This commit is contained in:
Shahram Najm 2015-06-01 17:07:16 +01:00
parent e3389fe601
commit 26ae520583
9 changed files with 412 additions and 426 deletions

View File

@ -691,7 +691,7 @@ int grib_accessor_has_attributes(grib_accessor* a) {
}
grib_accessor* grib_accessor_get_attribute(grib_accessor* a,const char* name) {
int i=0,index=0;
int index=0;
char* p=0;
char* basename=NULL;
char* attribute_name=NULL;
@ -703,8 +703,8 @@ grib_accessor* grib_accessor_get_attribute(grib_accessor* a,const char* name) {
} else {
size_t size=p-name;
attribute_name=p+2;
basename=grib_context_malloc_clear(a->parent->h->context,size+1);
basename=memcpy(basename,name,size);
basename=(char*)grib_context_malloc_clear(a->parent->h->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);
if (acc) return grib_accessor_get_attribute(acc,attribute_name);
@ -712,11 +712,13 @@ grib_accessor* grib_accessor_get_attribute(grib_accessor* a,const char* name) {
}
}
grib_accessors_list* grib_accessors_list_create(grib_context* c) {
return grib_context_malloc_clear(c,sizeof(grib_accessors_list));
grib_accessors_list* grib_accessors_list_create(grib_context* c)
{
return (grib_accessors_list*)grib_context_malloc_clear(c,sizeof(grib_accessors_list));
}
void grib_accessors_list_push(grib_accessors_list* al,grib_accessor* a) {
void grib_accessors_list_push(grib_accessors_list* al,grib_accessor* a)
{
grib_accessors_list* last;
grib_context* c=a->parent->h->context;
@ -732,8 +734,9 @@ void grib_accessors_list_push(grib_accessors_list* al,grib_accessor* a) {
}
}
grib_accessors_list* grib_accessors_list_last(grib_accessors_list* al) {
grib_accessors_list* last=al;
grib_accessors_list* grib_accessors_list_last(grib_accessors_list* al)
{
/*grib_accessors_list* last=al;*/
grib_accessors_list* next=al->next;
/*

View File

@ -178,7 +178,7 @@ char** str_split(char* a_str, const char a_delim)
knows where the list of returned strings ends. */
count++;
result = malloc(sizeof(char*) * count);
result = (char**)malloc(sizeof(char*) * count);
if (result)
{

View File

@ -360,7 +360,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]=grib_context_malloc_clear(a->parent->h->context,length);
v[0]=(char*)grib_context_malloc_clear(a->parent->h->context,length);
grib_unpack_string(a,v[0],&length);
*len=1;

View File

@ -134,7 +134,6 @@ static void init_class(grib_accessor_class* c)
/* END_CLASS_IMP */
static long compute_byte_count(grib_accessor* a){
grib_accessor_unexpanded_descriptors* self = (grib_accessor_unexpanded_descriptors*)a;
long numberOfUnexpandedDescriptors;
@ -150,7 +149,6 @@ static long compute_byte_count(grib_accessor* a){
return 2*numberOfUnexpandedDescriptors;
}
static void init(grib_accessor* a, const long len , grib_arguments* args )
{
grib_accessor_unexpanded_descriptors* self = (grib_accessor_unexpanded_descriptors*)a;
@ -201,9 +199,7 @@ static int unpack_long (grib_accessor* a, long* val, size_t *len)
y=grib_decode_unsigned_long(a->parent->h->buffer->data,&pos,8);
*v++=f*100000+x*1000+y;
}
*len = rlen;
return GRIB_SUCCESS;
}
@ -215,8 +211,7 @@ static int pack_long (grib_accessor* a, const long* val, size_t *len)
unsigned char* buf = NULL;
size_t buflen=*len*2;
buf=grib_context_malloc_clear(a->parent->h->context,buflen);
buf=(unsigned char*)grib_context_malloc_clear(a->parent->h->context,buflen);
for (i=0;i<*len;i++) {
f=val[i]/100000;
@ -231,7 +226,6 @@ static int pack_long (grib_accessor* a, const long* val, size_t *len)
/* update_size(a,buflen); */
return ret;
}
static long byte_count(grib_accessor* a){

View File

@ -24,7 +24,7 @@ bufr_descriptor* grib_bufr_descriptor_clone(bufr_descriptor* d) {
if (!d) return NULL;
cd=grib_context_malloc_clear(d->context,sizeof(bufr_descriptor));
cd=(bufr_descriptor*)grib_context_malloc_clear(d->context,sizeof(bufr_descriptor));
cd->code=d->code;
cd->F=d->F;

View File

@ -51,9 +51,7 @@ struct grib_keys_hash { char* name; int id;};
#endif
#endif
static unsigned int
hash_keys (str, len)
register const char *str;
register unsigned int len;
hash_keys (const char *str, unsigned int len)
{
static unsigned short asso_values[] =
{
@ -7171,9 +7169,7 @@ static struct grib_keys_hash wordlist[] =
#endif
#endif
struct grib_keys_hash *
grib_keys_hash_get (str, len)
register const char *str;
register unsigned int len;
grib_keys_hash_get (const char *str, unsigned int len)
{
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{

View File

@ -284,7 +284,7 @@ int grib_accessors_list_print(grib_accessors_list* al,const char* name,int type,
} else {
int i=0;
int cols=0;
cvals=grib_context_malloc_clear(h->context,sizeof(char*)*size);
cvals=(char**)grib_context_malloc_clear(h->context,sizeof(char*)*size);
grib_accessors_list_unpack_string(al,cvals,&size);
for (i=0;i<size;i++) {
*newline=1;

View File

@ -23,7 +23,6 @@ GRIB_INLINE static int strcmp(const char* a,const char* b) {
}
#endif
static int matching(grib_accessor* a,const char* name,const char* name_space)
{
int i = 0;
@ -41,7 +40,6 @@ static int matching(grib_accessor* a,const char* name,const char* name_space)
return 0;
}
static grib_accessor* search(grib_section* s,const char* name,const char* name_space)
{
@ -154,20 +152,19 @@ char* get_rank(const char* name,long *rank) {
} else {
grib_context* c=grib_context_get_default();
len=p-name;
ret=grib_context_malloc_clear(c,len);
ret=(char*)grib_context_malloc_clear(c,len);
memcpy(ret,name,len-1);
}
}
return ret;
}
char* get_condition(const char* name,codes_condition* condition) {
char* get_condition(const char* name,codes_condition* condition)
{
char* equal=(char*)name;
char* endCondition=NULL;
char* startLeft=NULL;
char* str=NULL;
char* end=NULL;
size_t len;
long lval;
double dval;
grib_context* c=grib_context_get_default();
@ -183,7 +180,7 @@ char* get_condition(const char* name,codes_condition* condition) {
while (*endCondition!=0 && *endCondition!='/') endCondition++;
if (*endCondition==0) return NULL;
str=grib_context_malloc_clear(c,strlen(name));
str=(char*)grib_context_malloc_clear(c,strlen(name));
memcpy(str,equal+1,endCondition-equal-1);
end=NULL;
@ -201,7 +198,7 @@ char* get_condition(const char* name,codes_condition* condition) {
if (condition->rightType!=GRIB_TYPE_UNDEFINED) {
strcpy(str,endCondition+1);
condition->left=grib_context_malloc_clear(c,equal-name);
condition->left=(char*)grib_context_malloc_clear(c,equal-name);
memcpy(condition->left,name+1,equal-name-1);
} else {
grib_context_free(c,str);
@ -292,7 +289,7 @@ static grib_accessors_list* search_by_condition(grib_handle* h,const char* name,
grib_accessor* data=search_and_cache(h,"dataAccessors",0);
if (data && condition->left) {
al=accessor_bufr_data_array_get_dataAccessors(data);
result=grib_context_malloc_clear(al->accessor->parent->h->context,sizeof(grib_accessors_list));
result=(grib_accessors_list*)grib_context_malloc_clear(al->accessor->parent->h->context,sizeof(grib_accessors_list));
search_accessors_list_by_condition(al,name,condition,result);
if (!result->accessor) {
grib_accessors_list_delete(h->context,result);
@ -317,7 +314,7 @@ grib_accessors_list* grib_find_accessors_list(grib_handle* h,const char* name) {
grib_accessor* a=NULL;
if (name[0]=='/') {
condition=grib_context_malloc_clear(h->context,sizeof(codes_condition));
condition=(codes_condition*)grib_context_malloc_clear(h->context,sizeof(codes_condition));
str=get_condition(name,condition);
if (str) {
al=search_by_condition(h,str,condition);
@ -329,13 +326,13 @@ grib_accessors_list* grib_find_accessors_list(grib_handle* h,const char* name) {
} else if (has_rank(name)) {
a=grib_find_accessor(h, name);
if (a) {
al=grib_context_malloc_clear(h->context,sizeof(grib_accessors_list));
al=(grib_accessors_list*)grib_context_malloc_clear(h->context,sizeof(grib_accessors_list));
grib_accessors_list_push(al,a);
}
} else {
a=grib_find_accessor(h, name);
if (a) {
al=grib_context_malloc_clear(h->context,sizeof(grib_accessors_list));
al=(grib_accessors_list*)grib_context_malloc_clear(h->context,sizeof(grib_accessors_list));
grib_find_same_and_push(al,a);
}
}
@ -347,7 +344,6 @@ static grib_accessor* search_and_cache(grib_handle* h, const char* name,const ch
{
char* str=0;
grib_accessor* a=NULL;
codes_condition* condition=NULL;
long rank;
str=get_rank(name,&rank);
@ -412,8 +408,8 @@ char* grib_split_name_attribute(grib_context* c,const char* name,char* attribute
return (char*)name;
}
size=p-name;
accessor_name=grib_context_malloc_clear(c,size+1);
accessor_name=memcpy(accessor_name,name,size);
accessor_name=(char*)grib_context_malloc_clear(c,size+1);
accessor_name=(char*)memcpy(accessor_name,name,size);
p+=2;
strcpy(attribute_name,p);
return accessor_name;
@ -493,6 +489,3 @@ grib_accessor* grib_find_accessor_fast(grib_handle* h, const char* name)
return a;
}

View File

@ -243,30 +243,30 @@ grib_handle* merge(grib_handle* h1,grib_handle* h2) {
grib_get_long(h,"numberOfPoints",&n);
grib_get_double(h,"missingValue",&missingValue);
v=grib_context_malloc_clear(h->context,sizeof(double)*n);
v=(double*)grib_context_malloc_clear(h->context,sizeof(double)*n);
for (i=0;i<n;i++) v[i]=1.0;
sn=n;
grib_set_double_array(h,"values",v,sn);
for (i=0;i<n;i++) v[i]=missingValue;
lat=grib_context_malloc_clear(h->context,sizeof(double)*n);
lon=grib_context_malloc_clear(h->context,sizeof(double)*n);
lat=(double*)grib_context_malloc_clear(h->context,sizeof(double)*n);
lon=(double*)grib_context_malloc_clear(h->context,sizeof(double)*n);
sn=n;
grib_get_double_array(h,"latitudes",lat,&sn);
grib_get_double_array(h,"longitudes",lon,&sn);
grib_get_long(h1,"numberOfPoints",&n1);
v1=grib_context_malloc_clear(h->context,sizeof(double)*n1);
lat1=grib_context_malloc_clear(h->context,sizeof(double)*n1);
lon1=grib_context_malloc_clear(h->context,sizeof(double)*n1);
v1=(double*)grib_context_malloc_clear(h->context,sizeof(double)*n1);
lat1=(double*)grib_context_malloc_clear(h->context,sizeof(double)*n1);
lon1=(double*)grib_context_malloc_clear(h->context,sizeof(double)*n1);
sn=n1;
grib_get_double_array(h1,"latitudes",lat1,&sn);
grib_get_double_array(h1,"longitudes",lon1,&sn);
grib_get_double_array(h1,"values",v1,&sn);
grib_get_long(h2,"numberOfPoints",&n2);
v2=grib_context_malloc_clear(h->context,sizeof(double)*n2);
lat2=grib_context_malloc_clear(h->context,sizeof(double)*n2);
lon2=grib_context_malloc_clear(h->context,sizeof(double)*n2);
v2=(double*)grib_context_malloc_clear(h->context,sizeof(double)*n2);
lat2=(double*)grib_context_malloc_clear(h->context,sizeof(double)*n2);
lon2=(double*)grib_context_malloc_clear(h->context,sizeof(double)*n2);
sn=n2;
grib_get_double_array(h2,"latitudes",lat2,&sn);
grib_get_double_array(h2,"longitudes",lon2,&sn);