Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Constify pointer and reference parameters in src/surf/.
[simgrid.git] / src / xbt / dict.cpp
index f6742fb..1b33417 100644 (file)
@@ -130,13 +130,11 @@ static void xbt_dict_rehash(xbt_dict_t dict)
  * @param key the key to set the new data
  * @param key_len the size of the @a key
  * @param data the data to add in the dict
- * @param free_ctn unused parameter (kept for compatibility)
  *
  * Set the @a data in the structure under the @a key, which can be any kind of data, as long as its length is provided
  * in @a key_len.
  */
-void xbt_dict_set_ext(xbt_dict_t dict, const char* key, int key_len, void* data,
-                      XBT_ATTRIB_UNUSED void_f_pvoid_t free_ctn)
+void xbt_dict_set_ext(xbt_dict_t dict, const char* key, int key_len, void* data)
 {
   unsigned int hash_code = xbt_str_hash_ext(key, key_len);
 
@@ -178,13 +176,12 @@ void xbt_dict_set_ext(xbt_dict_t dict, const char* key, int key_len, void* data,
  * @param dict the dict
  * @param key the key to set the new data
  * @param data the data to add in the dict
- * @param free_ctn unused parameter (kept for compatibility)
  *
- * set the @a data in the structure under the @a key, which is anull terminated string.
+ * set the @a data in the structure under the @a key, which is a null terminated string.
  */
-void xbt_dict_set(xbt_dict_t dict, const char *key, void *data, void_f_pvoid_t free_ctn)
+void xbt_dict_set(xbt_dict_t dict, const char* key, void* data)
 {
-  xbt_dict_set_ext(dict, key, strlen(key), data, free_ctn);
+  xbt_dict_set_ext(dict, key, strlen(key), data);
 }
 
 /**
@@ -200,7 +197,7 @@ void xbt_dict_set(xbt_dict_t dict, const char *key, void *data, void_f_pvoid_t f
 void *xbt_dict_get_ext(xbt_dict_t dict, const char *key, int key_len)
 {
   unsigned int hash_code = xbt_str_hash_ext(key, key_len);
-  xbt_dictelm_t current = dict->table[hash_code & dict->table_size];
+  const s_xbt_dictelm* current = dict->table[hash_code & dict->table_size];
 
   while (current != nullptr && (hash_code != current->hash_code || key_len != current->key_len
           || memcmp(key, current->key, key_len))) {
@@ -217,7 +214,7 @@ void *xbt_dict_get_ext(xbt_dict_t dict, const char *key, int key_len)
 void *xbt_dict_get_or_null_ext(xbt_dict_t dict, const char *key, int key_len)
 {
   unsigned int hash_code = xbt_str_hash_ext(key, key_len);
-  xbt_dictelm_t current = dict->table[hash_code & dict->table_size];
+  const s_xbt_dictelm* current = dict->table[hash_code & dict->table_size];
 
   while (current != nullptr && (hash_code != current->hash_code || key_len != current->key_len
           || memcmp(key, current->key, key_len))) {
@@ -238,7 +235,7 @@ void *xbt_dict_get_or_null_ext(xbt_dict_t dict, const char *key, int key_len)
 char *xbt_dict_get_key(xbt_dict_t dict, const void *data)
 {
   for (int i = 0; i <= dict->table_size; i++) {
-    xbt_dictelm_t current = dict->table[i];
+    const s_xbt_dictelm* current = dict->table[i];
     while (current != nullptr) {
       if (current->content == data)
         return current->key;
@@ -288,7 +285,7 @@ xbt_dictelm_t xbt_dict_get_elm(xbt_dict_t dict, const char *key)
  */
 void *xbt_dict_get_or_null(xbt_dict_t dict, const char *key)
 {
-  xbt_dictelm_t current = xbt_dict_get_elm_or_null(dict, key);
+  const s_xbt_dictelm* current = xbt_dict_get_elm_or_null(dict, key);
 
   if (current == nullptr)
     return nullptr;