From 9449b8bed266d65e819a1de8ff3a7eff80d52abe Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Tue, 23 Mar 2021 14:31:08 +0100 Subject: [PATCH] Kill unused dynar functions. --- ChangeLog | 3 ++- include/xbt/dynar.h | 14 +++----------- src/xbt/dynar.cpp | 47 +-------------------------------------------- 3 files changed, 6 insertions(+), 58 deletions(-) diff --git a/ChangeLog b/ChangeLog index ecd5a257d4..471c1d2c83 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,7 +23,8 @@ S4U: on between two (possibly remote) hosts. XBT: - - Drop simgrid::xbt::demangle. Please use boost::core::demangle instead. + - Drop simgrid::xbt::demangle(). Please use boost::core::demangle() instead. + - Drop xbt_dynar_cursor_rm(), xbt_dynar_search_or_negative(), xbt_dynar_to_array(). C binding and interface: - Rename (lowercase) functions sg_actor_get_PID, sg_actor_get_PPID, sg_actor_by_PID. diff --git a/include/xbt/dynar.h b/include/xbt/dynar.h index 2a826134b1..aaa4203954 100644 --- a/include/xbt/dynar.h +++ b/include/xbt/dynar.h @@ -52,9 +52,8 @@ SG_BEGIN_DECL * @skip end_of_doxygen * @until } * - * Note that if you use dynars to store pointed data, the xbt_dynar_search(), xbt_dynar_search_or_negative() and - * xbt_dynar_member() won't be for you. Instead of comparing your pointed elements, they compare the pointer to them. - * See the documentation of xbt_dynar_search() for more info. + * Note that if you use dynars to store pointed data, xbt_dynar_member() won't be for you. Instead of comparing your + * pointed elements, it compares the pointer to them. */ /** @defgroup XBT_dynar_cons Dynar constructor and destructor * @ingroup XBT_dynar @@ -82,10 +81,8 @@ XBT_PUBLIC void xbt_dynar_get_cpy(const_xbt_dynar_t dynar, unsigned long idx, vo XBT_PUBLIC void xbt_dynar_insert_at(xbt_dynar_t dynar, int idx, const void* src); XBT_PUBLIC void xbt_dynar_remove_at(xbt_dynar_t dynar, int idx, void* dst); -XBT_PUBLIC signed int xbt_dynar_search_or_negative(const_xbt_dynar_t dynar, const void* elem); XBT_PUBLIC int xbt_dynar_member(const_xbt_dynar_t dynar, const void* elem); XBT_PUBLIC void xbt_dynar_sort(const_xbt_dynar_t dynar, int_f_cpvoid_cpvoid_t compar_fn); -XBT_PUBLIC void* xbt_dynar_to_array(xbt_dynar_t dynar); /** @} */ /** @defgroup XBT_dynar_misc Dynar miscellaneous functions @@ -163,16 +160,11 @@ XBT_PUBLIC void* xbt_dynar_pop_ptr(xbt_dynar_t dynar); /** @defgroup XBT_dynar_cursor Cursors on dynar * @ingroup XBT_dynar * - * Cursors are used to iterate over the structure. Never add elements to the DynArr during the traversal. To remove - * elements, use the xbt_dynar_cursor_rm() function. - * - * Do not call these function directly, but only within the xbt_dynar_foreach macro. + * Cursors are used to iterate over the structure. Never add elements to the DynArr during the traversal. * * @{ */ -XBT_PUBLIC void xbt_dynar_cursor_rm(xbt_dynar_t dynar, unsigned int* cursor); - /* * @warning DO NOT USE THIS STRUCTURE DIRECTLY! Instead, use the public interface: * This was made public to allow: diff --git a/src/xbt/dynar.cpp b/src/xbt/dynar.cpp index 8fc42eafbd..2213a3cbeb 100644 --- a/src/xbt/dynar.cpp +++ b/src/xbt/dynar.cpp @@ -290,28 +290,10 @@ void xbt_dynar_remove_at(xbt_dynar_t dynar, int idx, void* object) dynar->used--; } -/** @brief Returns the position of the element in the dynar (or -1 if not found) - * - * Beware that if your dynar contains pointed values (such as strings) instead of scalar, this function is probably not - * what you want. Check the documentation of xbt_dynar_search() for more info. - * - * Note that usually, the dynar indices are unsigned integers. If you have more than 2 million elements in your dynar, - * this very function will not work (but the other will). - */ -signed int xbt_dynar_search_or_negative(const_xbt_dynar_t dynar, const void* elem) -{ - for (unsigned long it = 0; it < dynar->used; it++) - if (not memcmp(_xbt_dynar_elm(dynar, it), elem, dynar->elmsize)) { - return it; - } - - return -1; -} - /** @brief Returns a boolean indicating whether the element is part of the dynar * * Beware that if your dynar contains pointed values (such as strings) instead of scalar, this function is probably not - * what you want. Check the documentation of xbt_dynar_search() for more info. + * what you want. */ int xbt_dynar_member(const_xbt_dynar_t dynar, const void* elem) { @@ -399,16 +381,6 @@ void xbt_dynar_map(const_xbt_dynar_t dynar, void_f_pvoid_t op) } } -/** @brief Removes and free the entry pointed by the cursor - * - * This function can be used while traversing without problem. - */ -void xbt_dynar_cursor_rm(xbt_dynar_t dynar, unsigned int* cursor) -{ - xbt_dynar_remove_at(dynar, *cursor, nullptr); - *cursor -= 1; -} - /** @brief Sorts a dynar according to the function compar_fn * * This function simply apply the classical qsort(3) function to the data stored in the dynar. @@ -440,20 +412,3 @@ void xbt_dynar_sort(const_xbt_dynar_t dynar, int_f_cpvoid_cpvoid_t compar_fn) if (dynar->data != nullptr) qsort(dynar->data, dynar->used, dynar->elmsize, compar_fn); } - -/** @brief Transform a dynar into a nullptr terminated array. - * - * @param dynar the dynar to transform - * @return pointer to the first element of the array - * - * Note: The dynar won't be usable afterwards. - */ -void* xbt_dynar_to_array(xbt_dynar_t dynar) -{ - void *res; - xbt_dynar_shrink(dynar, 1); - memset(xbt_dynar_push_ptr(dynar), 0, dynar->elmsize); - res = dynar->data; - xbt_free(dynar); - return res; -} -- 2.20.1