diff options
Diffstat (limited to 'include/litmus/binheap.h')
-rw-r--r-- | include/litmus/binheap.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/include/litmus/binheap.h b/include/litmus/binheap.h index 412a4c7bd4bc..ce5539d72f4d 100644 --- a/include/litmus/binheap.h +++ b/include/litmus/binheap.h | |||
@@ -137,7 +137,7 @@ __binheap_decrease((orig_node), (handle)) | |||
137 | static inline void INIT_BINHEAP_NODE(struct binheap_node *n) | 137 | static inline void INIT_BINHEAP_NODE(struct binheap_node *n) |
138 | { | 138 | { |
139 | n->data = NULL; | 139 | n->data = NULL; |
140 | n->parent = NULL; | 140 | n->parent = BINHEAP_POISON; |
141 | n->left = NULL; | 141 | n->left = NULL; |
142 | n->right = NULL; | 142 | n->right = NULL; |
143 | n->ref = NULL; | 143 | n->ref = NULL; |
@@ -160,6 +160,12 @@ static inline int binheap_empty(struct binheap_handle *handle) | |||
160 | return(handle->root == NULL); | 160 | return(handle->root == NULL); |
161 | } | 161 | } |
162 | 162 | ||
163 | /* Returns true (1) if binheap node is in a heap. */ | ||
164 | static inline int binheap_is_in_heap(struct binheap_node *node) | ||
165 | { | ||
166 | return (node->parent != BINHEAP_POISON); | ||
167 | } | ||
168 | |||
163 | 169 | ||
164 | /* Update the node reference pointers. Same logic as Litmus binomial heap. */ | 170 | /* Update the node reference pointers. Same logic as Litmus binomial heap. */ |
165 | static inline void __update_ref(struct binheap_node *parent, | 171 | static inline void __update_ref(struct binheap_node *parent, |
@@ -516,6 +522,7 @@ static inline void __binheap_delete( | |||
516 | __binheap_delete_root(handle, node_to_delete); | 522 | __binheap_delete_root(handle, node_to_delete); |
517 | 523 | ||
518 | node_to_delete->data = temp_data; /* restore node data pointer */ | 524 | node_to_delete->data = temp_data; /* restore node data pointer */ |
525 | node_to_delete->parent = BINHEAP_POISON; /* poison the node */ | ||
519 | } | 526 | } |
520 | 527 | ||
521 | /** | 528 | /** |