Ejemplo n.º 1
0
/** @brief Add an element at the end of the dynar */
XBT_INLINE void xbt_dynar_push(xbt_dynar_t const dynar,
                               const void *const src)
{
  /* checks done in xbt_dynar_insert_at_ptr */
  memcpy(xbt_dynar_insert_at_ptr(dynar, dynar->used), src,
         dynar->elmsize);
}
Ejemplo n.º 2
0
/** @brief Make room at the end of the dynar for a new element, and return a pointer to it.
 *
 * You can then use regular affectation to set its value instead of relying
 * on the slow memcpy. This is what xbt_dynar_push_as() does.
 */
XBT_INLINE void *xbt_dynar_push_ptr(xbt_dynar_t const dynar)
{
  /* we have to inline xbt_dynar_insert_at_ptr here to make sure that
     dynar->used don't change between reading it and getting the lock
     within xbt_dynar_insert_at_ptr */
  return xbt_dynar_insert_at_ptr(dynar, dynar->used);
}
Ejemplo n.º 3
0
/** @brief Set the Nth dynar's element, expanding the dynar and sliding the previous values to the right
 *
 * Set the Nth element of a dynar, expanding the dynar if needed, and
 * moving the previously existing value and all subsequent ones to one
 * position right in the dynar.
 */
XBT_INLINE void
xbt_dynar_insert_at(xbt_dynar_t const dynar,
                    const int idx, const void *const src)
{

  /* checks done in xbt_dynar_insert_at_ptr */
  memcpy(xbt_dynar_insert_at_ptr(dynar, idx), src, dynar->elmsize);
}
Ejemplo n.º 4
0
Archivo: dynar.c Proyecto: R7R8/simgrid
/** @brief Make room at the end of the dynar for a new element, and return a pointer to it.
 *
 * You can then use regular affectation to set its value instead of relying on the slow memcpy. This is what
 * xbt_dynar_push_as() does.
 */
inline void *xbt_dynar_push_ptr(xbt_dynar_t const dynar)
{
  return xbt_dynar_insert_at_ptr(dynar, dynar->used);
}