You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The text was updated successfully, but these errors were encountered:
scossu
changed the title
Incorrect size report after cork_array_ensure_size and direct assignment
Incorrect size report after cork_array_ensure_sizeNov 2, 2019
I just noticed that I can change a->size in my program and that it affects cork_array_size, still the question remains: while cork_array_append automatically adjusts the size, shall a manual expansion not do so as well?
Hi Stefano! Sorry for the delay. This is the intended behavior — cork_array_ensure_size ensures that the capacity of the array is big enough to hold the requested number of elements, but you still have to use something like cork_array_append to add new elements and bump the size field. The documentation sort of mentions it, but I could add some text to make that more explicit.
To reproduce:
cork_array_ensure_size
cork_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?
The text was updated successfully, but these errors were encountered: