diff options
author | Chris Hall <chris.hall@highwayman.com> | 2011-05-24 11:04:43 +0100 |
---|---|---|
committer | Chris Hall <chris.hall@highwayman.com> | 2011-05-24 11:04:43 +0100 |
commit | e535bc959729262480a9702e71334002edee3f8c (patch) | |
tree | 43528fadad4c9b429cdda3524844a36a0ba283a3 /lib/vector.c | |
parent | 9a9466f1fdad6fb6c94c5ef8ddb1a687a7bcd874 (diff) | |
parent | 5f5809b14e76311d6fab751fe114b2ef495af10c (diff) | |
download | quagga-e535bc959729262480a9702e71334002edee3f8c.tar.bz2 quagga-e535bc959729262480a9702e71334002edee3f8c.tar.xz |
Merge branch 'master' of /git/quagga.euro-ix into pipework
Diffstat (limited to 'lib/vector.c')
-rw-r--r-- | lib/vector.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/vector.c b/lib/vector.c index cd81191f..74f61913 100644 --- a/lib/vector.c +++ b/lib/vector.c @@ -473,11 +473,13 @@ vector_move_item(vector v, vector_index_t i_dst, vector_index_t i_src) * * rider < 0 -- move to before the item at the given position * rider == 0 -- move to replace item at the given position - * rider > 0 -- insert after the item at the given position + * rider > 0 -- move to after the item at the given position * * NB: it is the caller's responsibility to release the any existing value * that will be replaced. * + * NB: replacing an item by itself (rider == 0, i_dst == i_src) deletes it ! + * * Move items and extend vector as required. */ extern void @@ -486,8 +488,17 @@ vector_move_item_here(vector v, vector_index_t i_dst, int rider, { if (rider != 0) { - if (rider > 0) - ++i_dst ; + if (i_src < i_dst) + { + if (rider < 0) + --i_dst ; /* moving up places src after dst */ + } + else if (i_src > i_dst) + { + if (rider > 0) + ++i_dst ; /* moving down places src before dst */ + } ; + vector_move_item(v, i_dst, i_src) ; } else |