From patchwork Tue Aug 9 12:06:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 73548 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp450000qga; Tue, 9 Aug 2016 05:07:33 -0700 (PDT) X-Received: by 10.107.28.11 with SMTP id c11mr115991768ioc.7.1470744453646; Tue, 09 Aug 2016 05:07:33 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id d64si30162307iod.240.2016.08.09.05.07.31; Tue, 09 Aug 2016 05:07:33 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id E46116158A; Tue, 9 Aug 2016 12:07:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 1884C60E87; Tue, 9 Aug 2016 12:07:24 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 74E4B60E4E; Tue, 9 Aug 2016 12:07:21 +0000 (UTC) Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com [74.125.82.53]) by lists.linaro.org (Postfix) with ESMTPS id F2D3861761 for ; Tue, 9 Aug 2016 12:06:39 +0000 (UTC) Received: by mail-wm0-f53.google.com with SMTP id f65so28501350wmi.0 for ; Tue, 09 Aug 2016 05:06:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=KlftTVSz3Gg4cPd4ioUQRuW6y19I9vYGaWnBxaXWdg8=; b=HK08PwMJNWFUWVtOtumTBZ6sJQ9sbGaTxh8Hyk15Tj6hnC4CEspc8flPnbebg6gYKw Idig96ZUICXTpj2s5FIoAL2+Z07ydqxzE2T+XxXRyyik2+guh0xeg5KXPP7Eb6iexAaf n655V5w2g+dJ2/9yYeoANc+G2kT0RsUVnNsu/9lCdOvb3smcckRyiAmyS55k+HhAIcsV R+9tyzxwjrbWZN/ZphLOWDLyHOHugYVKXLdgKTlsaKK3BkT8ddUMtt/0saq7wNUdx+uv 1jZ/KeyJwL11xAaSKLhH6x098PjAlNUtWf59d8WboINsRT1aKkY0Fn4DhlFahEMrNnvn Sk3g== X-Gm-Message-State: AEkoousV9SXzGJz67aN0mM+YKGuDxr/0cuVm14/MP7RELOimN/s9YJnW3HspdY3KXKKs+vuVu9k= X-Received: by 10.25.165.148 with SMTP id o142mr23918898lfe.166.1470744398565; Tue, 09 Aug 2016 05:06:38 -0700 (PDT) Received: from localhost.localdomain ([83.220.237.206]) by smtp.gmail.com with ESMTPSA id k63sm6546563lfe.48.2016.08.09.05.06.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Aug 2016 05:06:37 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Tue, 9 Aug 2016 15:06:32 +0300 Message-Id: <1470744392-8977-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.7.1.250.gff4ea60 X-Topics: patch Subject: [lng-odp] [PATCHv2] helper: hashtable: clean up internal functions name X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" No need for prefix for not interface local static functions. Suggested-by: Anders Roxell Signed-off-by: Maxim Uvarov --- helper/hashtable.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) -- 2.7.1.250.gff4ea60 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};