Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset a286eb4 in mainline


Ignore:
Timestamp:
2020-03-14T14:26:22Z (3 weeks ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
648135f
Parents:
a88af860
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-04-22 17:50:20)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2020-03-14 14:26:22)
Message:

dyn_array: Remove runtime pointer arithmetics

Location:
uspace/lib/c
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/adt/dyn_array.c

    ra88af860 ra286eb4  
    9191}
    9292
    93 void *_dyn_array_get(dyn_array_t *da, size_t index)
    94 {
    95         assert(index < da->size);
    96         return da->_data + (index * da->_item_size);
    97 }
    98 
    9993/** Grows/shrinks array so that it effeciently stores desired capacity
    10094 *
  • uspace/lib/c/include/adt/dyn_array.h

    ra88af860 ra286eb4  
    6767 */
    6868#define dyn_array_at(dyn_array, type, index)                                   \
    69         (*((type *) _dyn_array_get((dyn_array), index)))
     69        (*((type *) (dyn_array)->_data + index))
    7070
    7171/** Insert item at given position, shift rest of array
     
    108108
    109109extern int _dyn_array_initialize(dyn_array_t *, size_t, size_t);
    110 extern void *_dyn_array_get(dyn_array_t *, size_t);
    111110extern int  _dyn_array_reserve(dyn_array_t *, size_t);
    112111extern void _dyn_array_shift(dyn_array_t *, size_t, size_t);
Note: See TracChangeset for help on using the changeset viewer.