The block size for deque now scales based on the element size.
This means that the byte count in each block remains the same,
but with bigger elements, fewer elements may be stored in each
block (but still the same number of bytes). There is an exception
for elements that are very large, and a minimum element count
exists for the block in that case.
Add a tail pointer which is either NULL or points to the back of the list. This improves the performance when adding to the back of the list many times in a row.
In C89, negative integer division and modulo is implementation-defined.
Case 1: division rounds to 0 (C89/90, C99, C11, C18)
-9 / 7 -> -1
-9 % 7 -> -2
Case 2: division rounds to negative infinity (C89/90)
-9 / 7 -> -2
-9 % 7 -> 5
This change fixes the deque data structure from having negative division and modulo to prevent this implementation-defined behavior.
Refactor tests in order for the component or logic that they are testing to be contained into individual sub-tests instead of all tests being contained in one big test for the whole data structure.
Add testing for out-of-memory (OOM) conditions. This makes the source code now 100% covered.
Bug fix! A bug has been identified and fixed in the list data structure in the list_add_last function. This bug would occur when adding an item to the back of the list because the pointers were not being updated properly.
Minor Bug fix! A bug has been identified and fixed in the unordered_set, unordered_map, unordered_multiset, and unordered_multimap data structures in their respective unordered_xxx_put functions. This bug would occur in an out-of-memory condition, which would cause the size of the collection to increase without actually adding the new element to it.
Increase code coverage so that other than the out-of-memory conditions, the code is entirely covered.
Some areas of the code have been tweaked for performance optimizations.
Bug fix! A bug has been identified and fixed in the unordered_multiset data structure in the unordered_multiset_remove_all function.
This bug would occur when more than one entry exists in the bucket in which the element is occupying, and that element had a count of more than one.
Before this bug was fixed, it would result in a segmentation fault due to an off-by-one error in the trim function in the deque file. This off by one error was due to the fact that the end index points to the index after the last allocated block. However, in the trim function, the end index was treated as the last allocated block. Thus, in the case that the last block was completely full, the trim function would function as if there were another block after that block with one item in it. Thus, this block would be copied from without the memory being allocated.
Previously, queue would trim every 64 pops. However, this does not make sense for a queue with thousands of elements. Thus, now queue trims every time that the amount of trims times 1.5 is greater or equal to the size of the queue.
From the C standard, section 7.1.3:
- All identifiers that begin with an underscore and either an uppercase letter or another underscore are always reserved for any use.
- All identifiers that begin with an underscore are always reserved for use as identifiers with file scope in both the ordinary and tag name spaces.
The internal struct which defines each container used to start with an underscore followed by a lower case letter. The leading underscore for those identifiers have been replaced in order to prevent undefined behaviour.