Error messages

This commit is contained in:
Shahram Najm 2023-10-23 16:32:56 +01:00
parent 5be62bbcd2
commit 0fc243aea7
1 changed files with 11 additions and 22 deletions

View File

@ -73,8 +73,7 @@ int grib_fieldset_new_column(grib_fieldset* set, int id, char* key, int type)
set->columns[id].long_values = (long*)grib_context_malloc_clear(c, sizeof(long) * GRIB_START_ARRAY_SIZE); set->columns[id].long_values = (long*)grib_context_malloc_clear(c, sizeof(long) * GRIB_START_ARRAY_SIZE);
if (!set->columns[id].long_values) { if (!set->columns[id].long_values) {
grib_context_log(c, GRIB_LOG_ERROR, grib_context_log(c, GRIB_LOG_ERROR,
"grib_fieldset_new_column: Cannot malloc %ld bytes", "%s: Error allocating %zu bytes", __func__, sizeof(long) * GRIB_START_ARRAY_SIZE);
sizeof(long) * GRIB_START_ARRAY_SIZE);
err = GRIB_OUT_OF_MEMORY; err = GRIB_OUT_OF_MEMORY;
return err; return err;
} }
@ -83,8 +82,7 @@ int grib_fieldset_new_column(grib_fieldset* set, int id, char* key, int type)
set->columns[id].double_values = (double*)grib_context_malloc_clear(c, sizeof(double) * GRIB_START_ARRAY_SIZE); set->columns[id].double_values = (double*)grib_context_malloc_clear(c, sizeof(double) * GRIB_START_ARRAY_SIZE);
if (!set->columns[id].double_values) { if (!set->columns[id].double_values) {
grib_context_log(c, GRIB_LOG_ERROR, grib_context_log(c, GRIB_LOG_ERROR,
"grib_fieldset_new_column: Cannot malloc %ld bytes", "%s: Error allocating %zu bytes", __func__, sizeof(double) * GRIB_START_ARRAY_SIZE);
sizeof(double) * GRIB_START_ARRAY_SIZE);
err = GRIB_OUT_OF_MEMORY; err = GRIB_OUT_OF_MEMORY;
return err; return err;
} }
@ -93,8 +91,7 @@ int grib_fieldset_new_column(grib_fieldset* set, int id, char* key, int type)
set->columns[id].string_values = (char**)grib_context_malloc_clear(c, sizeof(char*) * GRIB_START_ARRAY_SIZE); set->columns[id].string_values = (char**)grib_context_malloc_clear(c, sizeof(char*) * GRIB_START_ARRAY_SIZE);
if (!set->columns[id].string_values) { if (!set->columns[id].string_values) {
grib_context_log(c, GRIB_LOG_ERROR, grib_context_log(c, GRIB_LOG_ERROR,
"grib_fieldset_new_column: Cannot malloc %ld bytes", "%s: Error allocating %zu bytes", __func__, sizeof(char*) * GRIB_START_ARRAY_SIZE);
sizeof(char*) * GRIB_START_ARRAY_SIZE);
err = GRIB_OUT_OF_MEMORY; err = GRIB_OUT_OF_MEMORY;
return err; return err;
} }
@ -171,8 +168,7 @@ static int grib_fieldset_columns_resize(grib_fieldset* set, size_t newsize)
newsize * sizeof(long)); newsize * sizeof(long));
if (!newlongs) { if (!newlongs) {
grib_context_log(c, GRIB_LOG_ERROR, grib_context_log(c, GRIB_LOG_ERROR,
"grib_fieldset_columns_resize: Cannot malloc %ld bytes", "%s: Error allocating %zu bytes", __func__, newsize - set->columns[i].values_array_size);
newsize - set->columns[i].values_array_size);
return GRIB_OUT_OF_MEMORY; return GRIB_OUT_OF_MEMORY;
} }
else else
@ -183,8 +179,7 @@ static int grib_fieldset_columns_resize(grib_fieldset* set, size_t newsize)
newsize * sizeof(double)); newsize * sizeof(double));
if (!newdoubles) { if (!newdoubles) {
grib_context_log(c, GRIB_LOG_ERROR, grib_context_log(c, GRIB_LOG_ERROR,
"grib_fieldset_columns_resize: Cannot malloc %ld bytes", "%s: Error allocating %zu bytes", __func__, newsize - set->columns[i].values_array_size);
newsize - set->columns[i].values_array_size);
return GRIB_OUT_OF_MEMORY; return GRIB_OUT_OF_MEMORY;
} }
else else
@ -195,8 +190,7 @@ static int grib_fieldset_columns_resize(grib_fieldset* set, size_t newsize)
newsize * sizeof(char*)); newsize * sizeof(char*));
if (!newstrings) { if (!newstrings) {
grib_context_log(c, GRIB_LOG_ERROR, grib_context_log(c, GRIB_LOG_ERROR,
"grib_fieldset_columns_resize: Cannot malloc %ld bytes", "%s: Error allocating %zu bytes", __func__, newsize - set->columns[i].values_array_size);
newsize - set->columns[i].values_array_size);
return GRIB_OUT_OF_MEMORY; return GRIB_OUT_OF_MEMORY;
} }
else else
@ -206,8 +200,7 @@ static int grib_fieldset_columns_resize(grib_fieldset* set, size_t newsize)
newerrors = (int*)grib_context_realloc(c, set->columns[i].errors, newsize * sizeof(int)); newerrors = (int*)grib_context_realloc(c, set->columns[i].errors, newsize * sizeof(int));
if (!newerrors) { if (!newerrors) {
grib_context_log(c, GRIB_LOG_ERROR, grib_context_log(c, GRIB_LOG_ERROR,
"grib_fieldset_columns_resize: Cannot malloc %ld bytes", "%s: Error allocating %zu bytes", __func__, newsize * sizeof(int));
newsize * sizeof(int));
return GRIB_OUT_OF_MEMORY; return GRIB_OUT_OF_MEMORY;
} }
else else
@ -332,8 +325,7 @@ static grib_fieldset* grib_fieldset_create_from_keys(grib_context* c, const char
msize = sizeof(grib_fieldset); msize = sizeof(grib_fieldset);
set = (grib_fieldset*)grib_context_malloc_clear(c, msize); set = (grib_fieldset*)grib_context_malloc_clear(c, msize);
if (!set) { if (!set) {
grib_context_log(c, GRIB_LOG_ERROR, grib_context_log(c, GRIB_LOG_ERROR, "%s: Error allocating %zu bytes", __func__, msize);
"grib_fieldset_create_from_keys: Cannot malloc %lu bytes", msize);
return NULL; return NULL;
} }
@ -357,7 +349,7 @@ static grib_fieldset* grib_fieldset_create_from_keys(grib_context* c, const char
set->columns = (grib_column*)grib_context_malloc_clear(c, sizeof(grib_column) * nkeys); set->columns = (grib_column*)grib_context_malloc_clear(c, sizeof(grib_column) * nkeys);
if (!set->columns) { if (!set->columns) {
grib_context_log(c, GRIB_LOG_ERROR, "grib_fieldset_create_from_keys: memory allocation error"); grib_context_log(c, GRIB_LOG_ERROR, "%s: memory allocation error", __func__);
*err = GRIB_OUT_OF_MEMORY; *err = GRIB_OUT_OF_MEMORY;
return NULL; return NULL;
} }
@ -417,7 +409,6 @@ int grib_fieldset_apply_where(grib_fieldset* set, const char* where_string)
// grib_math* m = NULL; // grib_math* m = NULL;
// m = grib_math_new(set->context, where_string, &err); // m = grib_math_new(set->context, where_string, &err);
// if (err || !m) return err; // if (err || !m) return err;
// print_math(m); // print_math(m);
// printf("\n"); // printf("\n");
// grib_math_delete(set->context, m); // grib_math_delete(set->context, m);
@ -816,8 +807,7 @@ static int grib_fieldset_resize_int_array(grib_int_array* a, size_t newsize)
el = (int*)grib_context_realloc(a->context, a->el, newsize); el = (int*)grib_context_realloc(a->context, a->el, newsize);
if (!el) { if (!el) {
grib_context_log(a->context, GRIB_LOG_ERROR, grib_context_log(a->context, GRIB_LOG_ERROR,
"grib_fieldset_resize_int_array: Cannot malloc %lu bytes", "%s: Error allocating %zu bytes", __func__, newsize);
newsize);
return GRIB_OUT_OF_MEMORY; return GRIB_OUT_OF_MEMORY;
} }
else else
@ -860,8 +850,7 @@ static int grib_fieldset_resize_fields(grib_fieldset* set, size_t newsize)
fields = (grib_field**)grib_context_realloc(set->context, set->fields, newsize * sizeof(grib_field*)); fields = (grib_field**)grib_context_realloc(set->context, set->fields, newsize * sizeof(grib_field*));
if (!fields) { if (!fields) {
grib_context_log(set->context, GRIB_LOG_ERROR, grib_context_log(set->context, GRIB_LOG_ERROR,
"grib_fieldset_resize_fields: Cannot malloc %lu bytes", "%s: Error allocating %zu bytes", __func__, newsize * sizeof(grib_field*));
newsize * sizeof(grib_field*));
return GRIB_OUT_OF_MEMORY; return GRIB_OUT_OF_MEMORY;
} }
else else