mirror of https://github.com/ecmwf/eccodes.git
BUFR dump C: make generated code easier to modify
This commit is contained in:
parent
8150d301a7
commit
5c95bcf7da
|
@ -189,9 +189,9 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
|
|||
|
||||
if (size>1) {
|
||||
fprintf(self->dumper.out," free(rvalues); rvalues = NULL;\n\n");
|
||||
fprintf(self->dumper.out," rvalues = (double*)malloc(%lu*sizeof(double));\n", (unsigned long)size);
|
||||
fprintf(self->dumper.out," if (!rvalues) { fprintf(stderr, \"Failed to allocate memory (rvalues).\\n\"); return 1; }\n");
|
||||
fprintf(self->dumper.out," size = %lu;", (unsigned long)size);
|
||||
fprintf(self->dumper.out," size = %lu;\n", (unsigned long)size);
|
||||
fprintf(self->dumper.out," rvalues = (double*)malloc(size * sizeof(double));\n");
|
||||
fprintf(self->dumper.out," if (!rvalues) { fprintf(stderr, \"Failed to allocate memory (rvalues).\\n\"); return 1; }");
|
||||
|
||||
icount=0;
|
||||
for (i=0; i<size-1; ++i) {
|
||||
|
@ -271,9 +271,9 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char*
|
|||
|
||||
if (size>1) {
|
||||
fprintf(self->dumper.out," free(rvalues); rvalues = NULL;\n");
|
||||
fprintf(self->dumper.out," rvalues = (double*)malloc(%lu*sizeof(double));\n", (unsigned long)size);
|
||||
fprintf(self->dumper.out," if (!rvalues) { fprintf(stderr, \"Failed to allocate memory (rvalues).\\n\"); return 1; }\n");
|
||||
fprintf(self->dumper.out," size = %lu;", (unsigned long)size);
|
||||
fprintf(self->dumper.out," size = %lu;\n", (unsigned long)size);
|
||||
fprintf(self->dumper.out," rvalues = (double*)malloc(size * sizeof(double));\n");
|
||||
fprintf(self->dumper.out," if (!rvalues) { fprintf(stderr, \"Failed to allocate memory (rvalues).\\n\"); return 1; }");
|
||||
|
||||
icount=0;
|
||||
for (i=0; i<size-1; ++i) {
|
||||
|
@ -363,9 +363,9 @@ static void dump_long(grib_dumper* d,grib_accessor* a, const char* comment)
|
|||
|
||||
if (size>1) {
|
||||
fprintf(self->dumper.out," free(ivalues); ivalues = NULL;\n\n");
|
||||
fprintf(self->dumper.out," ivalues = (long*)malloc(%lu*sizeof(long));\n", (unsigned long)size);
|
||||
fprintf(self->dumper.out," if (!ivalues) { fprintf(stderr, \"Failed to allocate memory (ivalues).\\n\"); return 1; }\n");
|
||||
fprintf(self->dumper.out," size = %lu;", (unsigned long)size);
|
||||
fprintf(self->dumper.out," size = %lu;\n", (unsigned long)size);
|
||||
fprintf(self->dumper.out," ivalues = (long*)malloc(size * sizeof(long));\n");
|
||||
fprintf(self->dumper.out," if (!ivalues) { fprintf(stderr, \"Failed to allocate memory (ivalues).\\n\"); return 1; }");
|
||||
|
||||
icount=0;
|
||||
for (i=0;i<size-1;i++) {
|
||||
|
@ -450,9 +450,9 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
|
|||
|
||||
if (size>1) {
|
||||
fprintf(self->dumper.out," free(ivalues); ivalues = NULL;\n");
|
||||
fprintf(self->dumper.out," ivalues = (long*)malloc(%lu*sizeof(long));\n", (unsigned long)size);
|
||||
fprintf(self->dumper.out," if (!ivalues) { fprintf(stderr, \"Failed to allocate memory (ivalues).\\n\"); return 1; }\n");
|
||||
fprintf(self->dumper.out," size = %lu;", (unsigned long)size);
|
||||
fprintf(self->dumper.out," size = %lu;\n", (unsigned long)size);
|
||||
fprintf(self->dumper.out," ivalues = (long*)malloc(size * sizeof(long));\n");
|
||||
fprintf(self->dumper.out," if (!ivalues) { fprintf(stderr, \"Failed to allocate memory (ivalues).\\n\"); return 1; }");
|
||||
|
||||
icount=0;
|
||||
for (i=0;i<size-1;i++) {
|
||||
|
@ -556,9 +556,9 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm
|
|||
}
|
||||
|
||||
fprintf(self->dumper.out," free(svalues);\n");
|
||||
fprintf(self->dumper.out," svalues = (char**)malloc(%lu * sizeof(char*));\n", (unsigned long)size);
|
||||
fprintf(self->dumper.out," if (!svalues) { fprintf(stderr, \"Failed to allocate memory (svalues).\\n\"); return 1; }\n");
|
||||
fprintf(self->dumper.out," size = %lu;\n", (unsigned long)size);
|
||||
fprintf(self->dumper.out," svalues = (char**)malloc(size * sizeof(char*));\n");
|
||||
fprintf(self->dumper.out," if (!svalues) { fprintf(stderr, \"Failed to allocate memory (svalues).\\n\"); return 1; }\n");
|
||||
|
||||
self->empty=0;
|
||||
values=(char**)grib_context_malloc_clear(c,size*sizeof(char*));
|
||||
|
@ -678,9 +678,9 @@ static void _dump_long_array(grib_handle* h, FILE* f, const char* key, const cha
|
|||
if (size==0) return;
|
||||
|
||||
fprintf(f," free(ivalues); ivalues = NULL;\n");
|
||||
fprintf(f," ivalues = (long*)malloc(%lu*sizeof(long));\n", (unsigned long)size);
|
||||
fprintf(f," if (!ivalues) { fprintf(stderr, \"Failed to allocate memory (ivalues).\\n\"); return 1; }\n");
|
||||
fprintf(f," size = %lu;", (unsigned long)size);
|
||||
fprintf(f," size = %lu;\n", (unsigned long)size);
|
||||
fprintf(f," ivalues = (long*)malloc(size * sizeof(long));\n");
|
||||
fprintf(f," if (!ivalues) { fprintf(stderr, \"Failed to allocate memory (ivalues).\\n\"); return 1; }");
|
||||
|
||||
val=(long*)grib_context_malloc_clear(h->context,sizeof(long)*size);
|
||||
grib_get_long_array(h,key,val,&size);
|
||||
|
|
Loading…
Reference in New Issue