Error messages: Print context

This commit is contained in:
shahramn 2024-02-24 22:21:36 +00:00
parent e7e8e5f9a2
commit f7869adb9c
7 changed files with 15 additions and 27 deletions

View File

@ -379,8 +379,7 @@ bufr_descriptor* accessor_bufr_elements_table_get_descriptor(grib_accessor* a, i
DEBUG_ASSERT(c);
v = (bufr_descriptor*)grib_context_malloc_clear(c, sizeof(bufr_descriptor));
if (!v) {
grib_context_log(c, GRIB_LOG_ERROR,
"accessor_bufr_elements_table_get_descriptor: unable to allocate %ld bytes\n", sizeof(bufr_descriptor));
grib_context_log(c, GRIB_LOG_ERROR, "%s: Unable to allocate %zu bytes", __func__, sizeof(bufr_descriptor));
*err = GRIB_OUT_OF_MEMORY;
return NULL;
}

View File

@ -1772,7 +1772,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
unsigned char* sec7 = reinterpret_cast<unsigned char*>(grib_context_malloc(a->context, size_sec7));
if (sec7 == NULL) {
grib_context_log(a->context, GRIB_LOG_ERROR, "%s packing: unable to allocate %d bytes", cclass_name, size_sec7);
grib_context_log(a->context, GRIB_LOG_ERROR, "%s: Unable to allocate %d bytes", cclass_name, size_sec7);
return GRIB_OUT_OF_MEMORY;
}

View File

@ -22,8 +22,7 @@ bufr_descriptors_array* grib_bufr_descriptors_array_new(grib_context* c, size_t
v = (bufr_descriptors_array*)grib_context_malloc(c, sizeof(bufr_descriptors_array));
if (!v) {
grib_context_log(c, GRIB_LOG_ERROR,
"bufr_descriptors_array_new unable to allocate %ld bytes\n", sizeof(bufr_descriptors_array));
grib_context_log(c, GRIB_LOG_ERROR, "%s: Unable to allocate %zu bytes", __func__, sizeof(bufr_descriptors_array));
return NULL;
}
v->context = c;
@ -34,7 +33,7 @@ bufr_descriptors_array* grib_bufr_descriptors_array_new(grib_context* c, size_t
v->number_of_pop_front = 0;
if (!v->v) {
grib_context_log(c, GRIB_LOG_ERROR,
"grib_bufr_descriptors_array_new unable to allocate %ld bytes\n", sizeof(bufr_descriptor) * size);
"%s: Unable to allocate %zu bytes", __func__, sizeof(bufr_descriptor) * size);
return NULL;
}
return v;
@ -73,8 +72,7 @@ static bufr_descriptors_array* grib_bufr_descriptors_array_resize_to(bufr_descri
newv = (bufr_descriptor**)grib_context_malloc_clear(c, newsize * sizeof(bufr_descriptor*));
if (!newv) {
grib_context_log(c, GRIB_LOG_ERROR,
"grib_bufr_descriptors_array_resize unable to allocate %ld bytes\n", sizeof(bufr_descriptor*) * newsize);
grib_context_log(c, GRIB_LOG_ERROR, "%s: Unable to allocate %zu bytes", __func__, sizeof(bufr_descriptor*) * newsize);
return NULL;
}

View File

@ -45,8 +45,7 @@ grib_darray* grib_darray_new(grib_context* c, size_t size, size_t incsize)
c = grib_context_get_default();
v = (grib_darray*)grib_context_malloc_clear(c, sizeof(grib_darray));
if (!v) {
grib_context_log(c, GRIB_LOG_ERROR,
"grib_darray_new unable to allocate %zu bytes", sizeof(grib_darray));
grib_context_log(c, GRIB_LOG_ERROR, "%s: Unable to allocate %zu bytes", __func__, sizeof(grib_darray));
return NULL;
}
v->size = size;
@ -55,8 +54,7 @@ grib_darray* grib_darray_new(grib_context* c, size_t size, size_t incsize)
v->context = c;
v->v = (double*)grib_context_malloc_clear(c, sizeof(double) * size);
if (!v->v) {
grib_context_log(c, GRIB_LOG_ERROR,
"grib_darray_new unable to allocate %zu bytes", sizeof(double) * size);
grib_context_log(c, GRIB_LOG_ERROR, "%s: Unable to allocate %zu bytes", __func__, sizeof(double) * size);
return NULL;
}
return v;
@ -73,7 +71,7 @@ static grib_darray* grib_darray_resize(grib_darray* v)
v->size = newsize;
if (!v->v) {
grib_context_log(c, GRIB_LOG_ERROR,
"grib_darray_resize unable to allocate %zu bytes", sizeof(double) * newsize);
"%s: Unable to allocate %zu bytes", __func__, sizeof(double) * newsize);
return NULL;
}
return v;

View File

@ -458,7 +458,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
* if (size==0) return;
* value=(char*)grib_context_malloc_clear(a->context,size);
* if (!value) {
* grib_context_log(a->context,GRIB_LOG_ERROR,"unable to allocate %d bytes",(int)size);
* grib_context_log(a->context,GRIB_LOG_ERROR,"Unable to allocate %zu bytes",size);
* return;
* }
*/

View File

@ -46,8 +46,7 @@ grib_iarray* grib_iarray_new(grib_context* c, size_t size, size_t incsize)
v = (grib_iarray*)grib_context_malloc(c, sizeof(grib_iarray));
if (!v) {
grib_context_log(c, GRIB_LOG_ERROR,
"grib_iarray_new unable to allocate %zu bytes", sizeof(grib_iarray));
grib_context_log(c, GRIB_LOG_ERROR, "%s: Unable to allocate %zu bytes", __func__, sizeof(grib_iarray));
return NULL;
}
v->context = c;
@ -57,8 +56,7 @@ grib_iarray* grib_iarray_new(grib_context* c, size_t size, size_t incsize)
v->v = (long*)grib_context_malloc(c, sizeof(long) * size);
v->number_of_pop_front = 0;
if (!v->v) {
grib_context_log(c, GRIB_LOG_ERROR,
"grib_iarray_new unable to allocate %zu bytes", sizeof(long) * size);
grib_context_log(c, GRIB_LOG_ERROR, "%s: Unable to allocate %zu bytes", __func__, sizeof(long) * size);
return NULL;
}
return v;
@ -98,8 +96,7 @@ static grib_iarray* grib_iarray_resize_to(grib_iarray* v, size_t newsize)
newv = (long*)grib_context_malloc_clear(c, newsize * sizeof(long));
if (!newv) {
grib_context_log(c, GRIB_LOG_ERROR,
"grib_iarray_resize unable to allocate %zu bytes", sizeof(long) * newsize);
grib_context_log(c, GRIB_LOG_ERROR, "%s: Unable to allocate %zu bytes", __func__, sizeof(long) * newsize);
return NULL;
}

View File

@ -242,17 +242,13 @@ static grib_index_key* grib_index_new_key(grib_context* c, grib_index_key* keys,
next = (grib_index_key*)grib_context_malloc_clear(c, sizeof(grib_index_key));
if (!next) {
grib_context_log(c, GRIB_LOG_ERROR,
"unable to allocate %ld bytes",
sizeof(grib_index_key));
grib_context_log(c, GRIB_LOG_ERROR, "Unable to allocate %zu bytes", sizeof(grib_index_key));
*err = GRIB_OUT_OF_MEMORY;
return NULL;
}
values = (grib_string_list*)grib_context_malloc_clear(c, sizeof(grib_string_list));
if (!values) {
grib_context_log(c, GRIB_LOG_ERROR,
"unable to allocate %ld bytes",
sizeof(grib_string_list));
grib_context_log(c, GRIB_LOG_ERROR, "Unable to allocate %zu bytes", sizeof(grib_string_list));
*err = GRIB_OUT_OF_MEMORY;
return NULL;
}
@ -1908,7 +1904,7 @@ grib_handle* codes_new_from_index(grib_index* index, int message_type, int* err)
sizeof(grib_field_list));
if (!index->fieldset) {
grib_context_log(index->context, GRIB_LOG_ERROR,
"unable to allocate %lu bytes", sizeof(grib_field_list));
"Unable to allocate %zu bytes", sizeof(grib_field_list));
return NULL;
}
index->current = index->fieldset;