Debugging: add method to print

This commit is contained in:
Shahram Najm 2022-12-20 17:42:44 +00:00
parent 1abceca228
commit 19b728c9f3
1 changed files with 15 additions and 1 deletions

View File

@ -10,6 +10,18 @@
#include "grib_api_internal.h" #include "grib_api_internal.h"
/* For debugging purposes */
void grib_sarray_print(const char* title, const grib_sarray* sarray)
{
size_t i;
Assert(sarray);
printf("%s: sarray.n=%zu \t", title, sarray->n);
for (i = 0; i < sarray->n; i++) {
printf("sarray[%zu]=%s\t", i, sarray->v[i]);
}
printf("\n");
}
grib_sarray* grib_sarray_new(grib_context* c, size_t size, size_t incsize) grib_sarray* grib_sarray_new(grib_context* c, size_t size, size_t incsize)
{ {
grib_sarray* v = NULL; grib_sarray* v = NULL;
@ -84,8 +96,10 @@ void grib_sarray_delete_content(grib_context* c, grib_sarray* v)
if (!c) if (!c)
c = grib_context_get_default(); c = grib_context_get_default();
for (i = 0; i < v->n; i++) { for (i = 0; i < v->n; i++) {
if (v->v[i]) if (v->v[i]) {
/*printf("grib_sarray_delete_content: %s %p\n", v->v[i], (void*)v->v[i]);*/
grib_context_free(c, v->v[i]); grib_context_free(c, v->v[i]);
}
v->v[i] = 0; v->v[i] = 0;
} }
v->n = 0; v->n = 0;