summaryrefslogtreecommitdiff
path: root/tests/test_vector.c
AgeCommit message (Collapse)Author
2015-05-11vector: Add REMOVE, ADD_SORTED and RESET macrosGeorge Joseph
Based on feedback from Corey Farrell and Y Ateya, a few new macros have been added... AST_VECTOR_REMOVE which takes a parameter to indicate if order should be preserved. AST_VECTOR_ADD_SORTED which adds an element to a sorted vector. AST_VECTOR_RESET which cleans all elements from the vector leaving the storage intact. Change-Id: I41d32dbdf7137e0557134efeff9f9f1064b58d14
2015-05-06vector: Additional enhancements and fixesGeorge Joseph
After using the new vector stuff for real I found... A bug in AST_VECTOR_INSERT_AT that could cause a seg fault. The callbacks needed to be closer to ao2_callback in behavior WRT to CMP_MATCH and CMP_STOP behavior and the ability to return a vector of matched entries. A pre-existing issue with APPEND and REPLACE was also fixed. I also added a new macro to test.h that acts like ast_test_validate but also accepts a return code variable and a cleanup label. As well as printing the error, it sets the rc variable to AST_TEST_FAIL and does a goto to the specified label on error. I had a local version of this in test_vector so I just moved it. ASTERISK-25045 Change-Id: I05e5e47fd02f61964be13b7e8942bab5d61b29cc
2015-05-05test_vector: Fix build breakage caused by ASTERISK_REGISTER_FILEGeorge Joseph
My 13 version of test_vector had an ASTERISK_REGISTER_FILE() macro call at the top which is only supported in master. Once removed builds are successful. Change-Id: I7cac8b669bed6de543bbf4e2eec3cffc9741acdd
2015-05-04vector: Traversal, retrieval, insert and locking enhancementsGeorge Joseph
Renamed AST_VECTOR_INSERT to AST_VECTOR_REPLACE because it really does replace not insert. The few users of AST_VECTOR_INSERT were refactored. Because these are macros, there should be no ABI compatibility issues. Added AST_VECTOR_INSERT_AT that actually inserts an element into the vector at a specific index pushing existing elements to the right. Added AST_VECTOR_GET_CMP that can retrieve from the vector based on a user-provided compare function. Added AST_VECTOR_CALLBACK function that will execute a function for each element in the vector. Similar to ao2_callback and ao2_callback_data functions although the vector callback can take a variable number of arguments. This should allow easy migration to a vector where a container might be too heavy. Added read/write locked vector and lock manipulation macros. Added unit tests. ASTERISK-25045 #close Change-Id: I2e07ecc709d2f5f91bcab8904e5e9340609b00e0