To reproduce:
- Reallocate space in an array with
cork_array_ensure_size
- Assign a value manually to the expanded elements of the array (probably optional but usefult to test the reallocation)
- Call
cork_array_size(array) or array->size (undocumented by the way, but seems to work exactly the same)
Expected result: the number of elements including the ones inserted manually.
Actual result: the number of element prior to expansion.
Example program:
#include <libcork/ds.h>
typedef cork_array(int) Array;
int main()
{
Array _a;
Array *a = &_a;
cork_array_init(a);
printf("%lu\n", a->size);
cork_array_append(a, 8);
printf("%lu\n", a->size);
cork_array_ensure_size(a, 2);
cork_array_at(a, 1) = 36;
printf("array->size: %lu\n", cork_array_size(a));
printf("cork_array_size: %lu\n", cork_array_size(a));
printf("At 1: %d\n", cork_array_at(a, 1));
return(0);
}
Output:
0
1
array->size: 1
cork_array_size: 1
At 1: 36
Is this is the expected behavior?
To reproduce:
cork_array_ensure_sizecork_array_size(array)orarray->size(undocumented by the way, but seems to work exactly the same)Expected result: the number of elements including the ones inserted manually.
Actual result: the number of element prior to expansion.
Example program:
Output:
Is this is the expected behavior?