OSDN Git Service

util/set: Do a full search when adding new items
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 5 Feb 2015 02:46:23 +0000 (18:46 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Sun, 8 Feb 2015 01:01:05 +0000 (17:01 -0800)
commit623c3a858d9c18f7d62a82597a488e7b54a4a4f4
treecb9d5e482e71e4d881d85aeb602efbca11cb6112
parentc9287e797b3e58bd4403f79d484e7235dc59262d
util/set: Do a full search when adding new items

Previously, the set_insert function would bail early if it found a deleted
slot that it could re-use.  However, this is a problem if the key being
inserted is already in the set but further down the list.  If this happens,
the element ends up getting inserted in the set twice.  This commit makes
it so that we walk over all of the possible entries for the given key and
then, if we don't find the key, place it in the available free entry we
found.

Reviewed-by: Eric Anholt <eric@anholt.net>
src/util/set.c