Commit d491480a by Celine Mercier

C: fixed remaining memory bug in array indexer

parent 073d98db
......@@ -30,20 +30,21 @@ index_t obi_index_array(Obi_indexer_p indexer, const void* value, uint8_t elt_si
index_t idx;
int32_t length_bytes;
// fprintf(stderr, "\nelt size in C: %u", elt_size);
// for (int i=0; i<value_length; i++)
// fprintf(stderr, "\nvalue %d", ((obibool_t*)value)[i]);
//fprintf(stderr, "\nelt size in C: %u, value len = %d\n", elt_size, value_length);
//for (int i=0; i<value_length; i++)
// fprintf(stderr, "%d - ", ((obiint_t*)value)[i]);
length_bytes = value_length * elt_size / 8;
//fprintf(stderr, "\nlength_bytes: %d", length_bytes);
// Encode value
value_b = obi_blob((byte_t*)value, elt_size, length_bytes, length_bytes);
if (value_b == NULL)
return -1;
// for (int i=0; i<value_length; i++)
// fprintf(stderr, "\nin blob: value %d", ((obibool_t*)(value_b->value))[i]);
//for (int i=0; i<value_length; i++)
// fprintf(stderr, "\nin blob: value %d\n", ((obiint_t*)(value_b->value))[i]);
// Add in the indexer
idx = obi_indexer_add(indexer, value_b);
......@@ -61,8 +62,14 @@ const void* obi_retrieve_array(Obi_indexer_p indexer, index_t idx, int32_t* valu
// Get encoded value
value_b = obi_indexer_get(indexer, idx);
//fprintf(stderr, "\nlen in blob: %d, elt size %u", value_b->length_decoded_value, value_b->element_size);
// Store array length
*value_length_p = (value_b->length_decoded_value) / (value_b->element_size) * 8;
*value_length_p = (value_b->length_decoded_value) * 8 / (value_b->element_size);
//fprintf(stderr, "\ngetting length: %d\n", *value_length_p);
//for (int i=0; i<*value_length_p; i++)
// fprintf(stderr, "\nin blob getting: value %d\n", ((obiint_t*)(value_b->value))[i]);
// Return pointer on mapped array
return ((void*) (value_b->value));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment