Changeset 92a7cfb1 in mainline


Ignore:
Timestamp:
2019-08-07T09:54:51Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
c64e254
Parents:
25a9fec
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-11-04 00:27:37)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-07 09:54:51)
Message:

dyn_array: Add sugar macro

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/adt/dyn_array.h

    r25a9fec r92a7cfb1  
    6868        (*((type *) (dyn_array)->_data + index))
    6969
     70
     71/** Access last element
     72 *
     73 * @return lvalue for the last item
     74 */
     75#define dyn_array_last(dyn_array, type)                                        \
     76        (*((type *) (dyn_array)->_data + ((dyn_array)->size - 1)))
     77
     78
    7079/** Insert item at given position, shift rest of array
    7180 *
     
    7786        size_t _index = (index);                                               \
    7887        dyn_array_t *_da = (dyn_array);                                        \
    79         int rc = dyn_array_reserve(_da, _da->size + 1);                       \
     88        int rc = dyn_array_reserve(_da, _da->size + 1);                        \
    8089        if (!rc) {                                                             \
    8190                _dyn_array_shift(_da, _index, 1);                              \
Note: See TracChangeset for help on using the changeset viewer.