From 88c15be7ff68a7b437fd78d6e5e0ede7aa1dbf6e Mon Sep 17 00:00:00 2001
From: Brian Norris <banorris@uci.edu>
Date: Fri, 10 Aug 2012 18:10:20 -0700
Subject: [PATCH] hashtable: rename ensureptr() to get_safe_ptr()

ensureptr() is kind of vague. This rename -- along with some better description
-- will help clarify what this function does.
---
 hashtable.h |  2 +-
 model.cc    | 16 ++++++++--------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/hashtable.h b/hashtable.h
index 2b703c5..b4054ec 100644
--- a/hashtable.h
+++ b/hashtable.h
@@ -153,7 +153,7 @@ template<typename _Key, typename _Val, typename _KeyInt, int _Shift=0, void * (*
 	}
 
 	/** Put a key entry into the table. */
-	_Val * ensureptr(_Key key) {
+	_Val * get_safe_ptr(_Key key) {
 		if (size > threshold)
 			resize(capacity << 1);
 
diff --git a/model.cc b/model.cc
index c4ee253..7c6684f 100644
--- a/model.cc
+++ b/model.cc
@@ -200,7 +200,7 @@ ModelAction * ModelChecker::get_last_conflict(ModelAction *act)
 			return NULL;
 	}
 	/* linear search: from most recent to oldest */
-	action_list_t *list = obj_map->ensureptr(act->get_location());
+	action_list_t *list = obj_map->get_safe_ptr(act->get_location());
 	action_list_t::reverse_iterator rit;
 	for (rit = list->rbegin(); rit != list->rend(); rit++) {
 		ModelAction *prev = *rit;
@@ -384,7 +384,7 @@ ModelAction * ModelChecker::process_rmw(ModelAction * act) {
  * @param rf The action that curr reads from. Must be a write.
  */
 void ModelChecker::r_modification_order(ModelAction * curr, const ModelAction *rf) {
-	std::vector<action_list_t> *thrd_lists = obj_thrd_map->ensureptr(curr->get_location());
+	std::vector<action_list_t> *thrd_lists = obj_thrd_map->get_safe_ptr(curr->get_location());
 	unsigned int i;
 	ASSERT(curr->is_read());
 
@@ -414,7 +414,7 @@ void ModelChecker::r_modification_order(ModelAction * curr, const ModelAction *r
 /** Updates the cyclegraph with the constraints imposed from the
  *  current read. */
 void ModelChecker::post_r_modification_order(ModelAction * curr, const ModelAction *rf) {
-	std::vector<action_list_t> *thrd_lists = obj_thrd_map->ensureptr(curr->get_location());
+	std::vector<action_list_t> *thrd_lists = obj_thrd_map->get_safe_ptr(curr->get_location());
 	unsigned int i;
 	ASSERT(curr->is_read());
 
@@ -453,7 +453,7 @@ void ModelChecker::post_r_modification_order(ModelAction * curr, const ModelActi
  * @param curr The current action. Must be a write.
  */
 void ModelChecker::w_modification_order(ModelAction * curr) {
-	std::vector<action_list_t> *thrd_lists = obj_thrd_map->ensureptr(curr->get_location());
+	std::vector<action_list_t> *thrd_lists = obj_thrd_map->get_safe_ptr(curr->get_location());
 	unsigned int i;
 	ASSERT(curr->is_write());
 
@@ -510,9 +510,9 @@ void ModelChecker::add_action_to_lists(ModelAction *act)
 	int tid = id_to_int(act->get_tid());
 	action_trace->push_back(act);
 
-	obj_map->ensureptr(act->get_location())->push_back(act);
+	obj_map->get_safe_ptr(act->get_location())->push_back(act);
 
-	std::vector<action_list_t> *vec = obj_thrd_map->ensureptr(act->get_location());
+	std::vector<action_list_t> *vec = obj_thrd_map->get_safe_ptr(act->get_location());
 	if (tid >= (int)vec->size())
 		vec->resize(next_thread_id);
 	(*vec)[tid].push_back(act);
@@ -538,7 +538,7 @@ ModelAction * ModelChecker::get_last_action(thread_id_t tid)
  */
 ModelAction * ModelChecker::get_last_seq_cst(const void *location)
 {
-	action_list_t *list = obj_map->ensureptr(location);
+	action_list_t *list = obj_map->get_safe_ptr(location);
 	/* Find: max({i in dom(S) | seq_cst(t_i) && isWrite(t_i) && samevar(t_i, t)}) */
 	action_list_t::reverse_iterator rit;
 	for (rit = list->rbegin(); rit != list->rend(); rit++)
@@ -626,7 +626,7 @@ void ModelChecker::check_promises(ClockVector *old_cv, ClockVector * merge_cv) {
  */
 void ModelChecker::build_reads_from_past(ModelAction *curr)
 {
-	std::vector<action_list_t> *thrd_lists = obj_thrd_map->ensureptr(curr->get_location());
+	std::vector<action_list_t> *thrd_lists = obj_thrd_map->get_safe_ptr(curr->get_location());
 	unsigned int i;
 	ASSERT(curr->is_read());
 
-- 
2.34.1