summaryrefslogtreecommitdiffstats
path: root/third_party/libevent/min_heap.h
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-20 20:23:54 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-20 20:23:54 +0000
commit78d4429cef4baac9bcdfc2396ce157016621c416 (patch)
treeca8e34515c63dd682d9b75b9bfc6113fcb0c2dfd /third_party/libevent/min_heap.h
parent9101b6b1b3de0a1e3c59325055707c58748651af (diff)
downloadchromium_src-78d4429cef4baac9bcdfc2396ce157016621c416.zip
chromium_src-78d4429cef4baac9bcdfc2396ce157016621c416.tar.gz
chromium_src-78d4429cef4baac9bcdfc2396ce157016621c416.tar.bz2
posix: upgrade libevent from 1.4.7 to 1.4.13
I took this opportunity to rejigger how we hacked around using an uninstalled libevent, to remove a TODO that mentioned danger in the README. Files to review: README.chromium and chromium.patch. The rest are probably rubber-stampable. Review URL: http://codereview.chromium.org/412006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32656 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/libevent/min_heap.h')
-rw-r--r--third_party/libevent/min_heap.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/third_party/libevent/min_heap.h b/third_party/libevent/min_heap.h
index d47e563..4fc83c0 100644
--- a/third_party/libevent/min_heap.h
+++ b/third_party/libevent/min_heap.h
@@ -86,7 +86,17 @@ int min_heap_erase(min_heap_t* s, struct event* e)
{
if(((unsigned int)-1) != e->min_heap_idx)
{
- min_heap_shift_down_(s, e->min_heap_idx, s->p[--s->n]);
+ struct event *last = s->p[--s->n];
+ unsigned parent = (e->min_heap_idx - 1) / 2;
+ /* we replace e with the last element in the heap. We might need to
+ shift it upward if it is less than its parent, or downward if it is
+ greater than one or both its children. Since the children are known
+ to be less than the parent, it can't need to shift both up and
+ down. */
+ if (e->min_heap_idx > 0 && min_heap_elem_greater(s->p[parent], last))
+ min_heap_shift_up_(s, e->min_heap_idx, last);
+ else
+ min_heap_shift_down_(s, e->min_heap_idx, last);
e->min_heap_idx = -1;
return 0;
}