diff mbox

[PATCHv2] helper: hashtable: clean up internal functions name

Message ID 1470744392-8977-1-git-send-email-maxim.uvarov@linaro.org
State New
Headers show

Commit Message

Maxim Uvarov Aug. 9, 2016, 12:06 p.m. UTC
No need for prefix for not interface local static functions.

Suggested-by: Anders Roxell <anders.roxell@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>

---
 helper/hashtable.c | 46 +++++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 23 deletions(-)

-- 
2.7.1.250.gff4ea60

Comments

Maxim Uvarov Aug. 11, 2016, 2:21 p.m. UTC | #1
ping, review is needed.

Maxim.

On 08/09/16 15:06, Maxim Uvarov wrote:
> No need for prefix for not interface local static functions.

>

> Suggested-by: Anders Roxell <anders.roxell@linaro.org>

> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>

> ---

>   helper/hashtable.c | 46 +++++++++++++++++++++++-----------------------

>   1 file changed, 23 insertions(+), 23 deletions(-)

>

> diff --git a/helper/hashtable.c b/helper/hashtable.c

> index 8bb1ae5..fbfef7f 100644

> --- a/helper/hashtable.c

> +++ b/helper/hashtable.c

> @@ -61,9 +61,9 @@ typedef struct {

>   	char name[ODPH_TABLE_NAME_LEN]; /**< table name */

>   } odph_hash_table_imp;

>   

> -odph_table_t odph_hash_table_create(const char *name, uint32_t capacity,

> -				    uint32_t key_size,

> -				    uint32_t value_size)

> +static odph_table_t hash_table_create(const char *name, uint32_t capacity,

> +				      uint32_t key_size,

> +				      uint32_t value_size)

>   {

>   	int i;

>   	uint32_t node_num;

> @@ -125,7 +125,7 @@ odph_table_t odph_hash_table_create(const char *name, uint32_t capacity,

>   	return (odph_table_t)tbl;

>   }

>   

> -int odph_hash_table_destroy(odph_table_t table)

> +static int hash_table_destroy(odph_table_t table)

>   {

>   	int ret;

>   

> @@ -146,7 +146,7 @@ int odph_hash_table_destroy(odph_table_t table)

>   	return ODPH_FAIL;

>   }

>   

> -odph_table_t odph_hash_table_lookup(const char *name)

> +static odph_table_t hash_table_lookup(const char *name)

>   {

>   	odph_hash_table_imp *hash_tbl;

>   

> @@ -164,7 +164,7 @@ odph_table_t odph_hash_table_lookup(const char *name)

>    * This hash algorithm is the most simple one, so we choose it as an DEMO

>    * User can use any other algorithm, like CRC...

>    */

> -uint16_t odp_key_hash(void *key, uint32_t key_size)

> +static uint16_t key_hash(void *key, uint32_t key_size)

>   {

>   	register uint32_t hash = 0;

>   	uint32_t idx = (key_size == 0 ? 1 : key_size);

> @@ -181,7 +181,7 @@ uint16_t odp_key_hash(void *key, uint32_t key_size)

>   /**

>    * Get an available node from pool

>    */

> -odph_hash_node *odp_hashnode_take(odph_table_t table)

> +static odph_hash_node *hashnode_take(odph_table_t table)

>   {

>   	odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;

>   	uint32_t idx;

> @@ -208,7 +208,7 @@ odph_hash_node *odp_hashnode_take(odph_table_t table)

>   /**

>    * Release an node to the pool

>    */

> -void odp_hashnode_give(odph_table_t table, odph_hash_node *node)

> +static void hashnode_give(odph_table_t table, odph_hash_node *node)

>   {

>   	odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;

>   

> @@ -221,7 +221,7 @@ void odp_hashnode_give(odph_table_t table, odph_hash_node *node)

>   }

>   

>   /* should make sure the input table exists and is available */

> -int odph_hash_put_value(odph_table_t table, void *key, void *value)

> +static int hash_put_value(odph_table_t table, void *key, void *value)

>   {

>   	odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;

>   	uint16_t hash = 0;

> @@ -232,7 +232,7 @@ int odph_hash_put_value(odph_table_t table, void *key, void *value)

>   		return ODPH_FAIL;

>   

>   	/* hash value is just the index of the list head in pool */

> -	hash = odp_key_hash(key, tbl->key_size);

> +	hash = key_hash(key, tbl->key_size);

>   

>   	odp_rwlock_write_lock(&tbl->lock_pool[hash]);

>   	/* First, check if the key already exist */

> @@ -249,7 +249,7 @@ int odph_hash_put_value(odph_table_t table, void *key, void *value)

>   	}

>   

>   	/*if the key is a new one, get a new hash node form the pool */

> -	node = odp_hashnode_take(table);

> +	node = hashnode_take(table);

>   	if (node == NULL) {

>   		odp_rwlock_write_unlock(&tbl->lock_pool[hash]);

>   		return ODPH_FAIL;

> @@ -268,8 +268,8 @@ int odph_hash_put_value(odph_table_t table, void *key, void *value)

>   }

>   

>   /* should make sure the input table exists and is available */

> -int odph_hash_get_value(odph_table_t table, void *key, void *buffer,

> -			uint32_t buffer_size)

> +static int hash_get_value(odph_table_t table, void *key, void *buffer,

> +			  uint32_t buffer_size)

>   {

>   	odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;

>   	uint16_t hash = 0;

> @@ -281,7 +281,7 @@ int odph_hash_get_value(odph_table_t table, void *key, void *buffer,

>   		return ODPH_FAIL;

>   

>   	/* hash value is just the index of the list head in pool */

> -	hash = odp_key_hash(key, tbl->key_size);

> +	hash = key_hash(key, tbl->key_size);

>   

>   	odp_rwlock_read_lock(&tbl->lock_pool[hash]);

>   

> @@ -306,7 +306,7 @@ int odph_hash_get_value(odph_table_t table, void *key, void *buffer,

>   }

>   

>   /* should make sure the input table exists and is available */

> -int odph_hash_remove_value(odph_table_t table, void *key)

> +static int hash_remove_value(odph_table_t table, void *key)

>   {

>   	odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;

>   	uint16_t hash = 0;

> @@ -316,7 +316,7 @@ int odph_hash_remove_value(odph_table_t table, void *key)

>   		return ODPH_FAIL;

>   

>   	/* hash value is just the index of the list head in pool */

> -	hash = odp_key_hash(key, tbl->key_size);

> +	hash = key_hash(key, tbl->key_size);

>   

>   	odp_rwlock_write_lock(&tbl->lock_pool[hash]);

>   

> @@ -324,7 +324,7 @@ int odph_hash_remove_value(odph_table_t table, void *key)

>   			   list_node)

>   	{

>   		if (memcmp(node->content, key, tbl->key_size) == 0) {

> -			odp_hashnode_give(table, node);

> +			hashnode_give(table, node);

>   			odp_rwlock_write_unlock(&tbl->lock_pool[hash]);

>   			return ODPH_SUCCESS;

>   		}

> @@ -336,10 +336,10 @@ int odph_hash_remove_value(odph_table_t table, void *key)

>   }

>   

>   odph_table_ops_t odph_hash_table_ops = {

> -	odph_hash_table_create,

> -	odph_hash_table_lookup,

> -	odph_hash_table_destroy,

> -	odph_hash_put_value,

> -	odph_hash_get_value,

> -	odph_hash_remove_value};

> +	hash_table_create,

> +	hash_table_lookup,

> +	hash_table_destroy,

> +	hash_put_value,

> +	hash_get_value,

> +	hash_remove_value};

>
diff mbox

Patch

diff --git a/helper/hashtable.c b/helper/hashtable.c
index 8bb1ae5..fbfef7f 100644
--- a/helper/hashtable.c
+++ b/helper/hashtable.c
@@ -61,9 +61,9 @@  typedef struct {
 	char name[ODPH_TABLE_NAME_LEN]; /**< table name */
 } odph_hash_table_imp;
 
-odph_table_t odph_hash_table_create(const char *name, uint32_t capacity,
-				    uint32_t key_size,
-				    uint32_t value_size)
+static odph_table_t hash_table_create(const char *name, uint32_t capacity,
+				      uint32_t key_size,
+				      uint32_t value_size)
 {
 	int i;
 	uint32_t node_num;
@@ -125,7 +125,7 @@  odph_table_t odph_hash_table_create(const char *name, uint32_t capacity,
 	return (odph_table_t)tbl;
 }
 
-int odph_hash_table_destroy(odph_table_t table)
+static int hash_table_destroy(odph_table_t table)
 {
 	int ret;
 
@@ -146,7 +146,7 @@  int odph_hash_table_destroy(odph_table_t table)
 	return ODPH_FAIL;
 }
 
-odph_table_t odph_hash_table_lookup(const char *name)
+static odph_table_t hash_table_lookup(const char *name)
 {
 	odph_hash_table_imp *hash_tbl;
 
@@ -164,7 +164,7 @@  odph_table_t odph_hash_table_lookup(const char *name)
  * This hash algorithm is the most simple one, so we choose it as an DEMO
  * User can use any other algorithm, like CRC...
  */
-uint16_t odp_key_hash(void *key, uint32_t key_size)
+static uint16_t key_hash(void *key, uint32_t key_size)
 {
 	register uint32_t hash = 0;
 	uint32_t idx = (key_size == 0 ? 1 : key_size);
@@ -181,7 +181,7 @@  uint16_t odp_key_hash(void *key, uint32_t key_size)
 /**
  * Get an available node from pool
  */
-odph_hash_node *odp_hashnode_take(odph_table_t table)
+static odph_hash_node *hashnode_take(odph_table_t table)
 {
 	odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;
 	uint32_t idx;
@@ -208,7 +208,7 @@  odph_hash_node *odp_hashnode_take(odph_table_t table)
 /**
  * Release an node to the pool
  */
-void odp_hashnode_give(odph_table_t table, odph_hash_node *node)
+static void hashnode_give(odph_table_t table, odph_hash_node *node)
 {
 	odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;
 
@@ -221,7 +221,7 @@  void odp_hashnode_give(odph_table_t table, odph_hash_node *node)
 }
 
 /* should make sure the input table exists and is available */
-int odph_hash_put_value(odph_table_t table, void *key, void *value)
+static int hash_put_value(odph_table_t table, void *key, void *value)
 {
 	odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;
 	uint16_t hash = 0;
@@ -232,7 +232,7 @@  int odph_hash_put_value(odph_table_t table, void *key, void *value)
 		return ODPH_FAIL;
 
 	/* hash value is just the index of the list head in pool */
-	hash = odp_key_hash(key, tbl->key_size);
+	hash = key_hash(key, tbl->key_size);
 
 	odp_rwlock_write_lock(&tbl->lock_pool[hash]);
 	/* First, check if the key already exist */
@@ -249,7 +249,7 @@  int odph_hash_put_value(odph_table_t table, void *key, void *value)
 	}
 
 	/*if the key is a new one, get a new hash node form the pool */
-	node = odp_hashnode_take(table);
+	node = hashnode_take(table);
 	if (node == NULL) {
 		odp_rwlock_write_unlock(&tbl->lock_pool[hash]);
 		return ODPH_FAIL;
@@ -268,8 +268,8 @@  int odph_hash_put_value(odph_table_t table, void *key, void *value)
 }
 
 /* should make sure the input table exists and is available */
-int odph_hash_get_value(odph_table_t table, void *key, void *buffer,
-			uint32_t buffer_size)
+static int hash_get_value(odph_table_t table, void *key, void *buffer,
+			  uint32_t buffer_size)
 {
 	odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;
 	uint16_t hash = 0;
@@ -281,7 +281,7 @@  int odph_hash_get_value(odph_table_t table, void *key, void *buffer,
 		return ODPH_FAIL;
 
 	/* hash value is just the index of the list head in pool */
-	hash = odp_key_hash(key, tbl->key_size);
+	hash = key_hash(key, tbl->key_size);
 
 	odp_rwlock_read_lock(&tbl->lock_pool[hash]);
 
@@ -306,7 +306,7 @@  int odph_hash_get_value(odph_table_t table, void *key, void *buffer,
 }
 
 /* should make sure the input table exists and is available */
-int odph_hash_remove_value(odph_table_t table, void *key)
+static int hash_remove_value(odph_table_t table, void *key)
 {
 	odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;
 	uint16_t hash = 0;
@@ -316,7 +316,7 @@  int odph_hash_remove_value(odph_table_t table, void *key)
 		return ODPH_FAIL;
 
 	/* hash value is just the index of the list head in pool */
-	hash = odp_key_hash(key, tbl->key_size);
+	hash = key_hash(key, tbl->key_size);
 
 	odp_rwlock_write_lock(&tbl->lock_pool[hash]);
 
@@ -324,7 +324,7 @@  int odph_hash_remove_value(odph_table_t table, void *key)
 			   list_node)
 	{
 		if (memcmp(node->content, key, tbl->key_size) == 0) {
-			odp_hashnode_give(table, node);
+			hashnode_give(table, node);
 			odp_rwlock_write_unlock(&tbl->lock_pool[hash]);
 			return ODPH_SUCCESS;
 		}
@@ -336,10 +336,10 @@  int odph_hash_remove_value(odph_table_t table, void *key)
 }
 
 odph_table_ops_t odph_hash_table_ops = {
-	odph_hash_table_create,
-	odph_hash_table_lookup,
-	odph_hash_table_destroy,
-	odph_hash_put_value,
-	odph_hash_get_value,
-	odph_hash_remove_value};
+	hash_table_create,
+	hash_table_lookup,
+	hash_table_destroy,
+	hash_put_value,
+	hash_get_value,
+	hash_remove_value};