]> Savannah Git Hosting - gnulib.git/commitdiff
hash: Rename hash_delete to hash_remove.
authorBruno Haible <bruno@clisp.org>
Sat, 17 Oct 2020 01:00:59 +0000 (03:00 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 17 Oct 2020 01:00:59 +0000 (03:00 +0200)
* lib/hash.h (hash_remove): Renamed from hash_delete.
(hash_delete): New declaration.
* lib/hash.c (hash_remove): Renamed from hash_delete.
(hash_delete): New function.
* tests/test-hash.c (main): Update.
* lib/fts-cycle.c (leave_dir): Likewise.
* NEWS: Mention the change.

ChangeLog
NEWS
lib/fts-cycle.c
lib/hash.c
lib/hash.h
tests/test-hash.c

index d8643b94cdd95fe4d293f3cde74cd521330273a4..3c87058ee1fe9c75bc8971e37d58bb45d6bc5c2f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2020-10-16  Bruno Haible  <bruno@clisp.org>
+
+       hash: Rename hash_delete to hash_remove.
+       * lib/hash.h (hash_remove): Renamed from hash_delete.
+       (hash_delete): New declaration.
+       * lib/hash.c (hash_remove): Renamed from hash_delete.
+       (hash_delete): New function.
+       * tests/test-hash.c (main): Update.
+       * lib/fts-cycle.c (leave_dir): Likewise.
+       * NEWS: Mention the change.
+
 2020-10-16  Bruno Haible  <bruno@clisp.org>
 
        hash, xhash: Make usable from C++.
diff --git a/NEWS b/NEWS
index 18465b260688da74fbc7952821dec1ab8a401f52..d76e3e77ce0321eda0b1ec215337f7aa02025219 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -60,6 +60,10 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
+2020-10-16  hash            This module deprecates the 'hash_delete' function
+                            using gcc's "deprecated" attribute.  Use the better-
+                            named 'hash_remove' equivalent.
+
 2020-08-24  diffseq         If you do not define NOTE_ORDERED to true,
                             the NOTE_DELETE and NOTE_INSERT actions might
                             not be done in order, to help cut down worst-case
index 46b5f618596f243b73b985e5e94d8e676dc8d0af..a2d59bebb149b7a453543b174acfedd5ee3295e9 100644 (file)
@@ -131,7 +131,7 @@ leave_dir (FTS *fts, FTSENT *ent)
       void *found;
       obj.dev = st->st_dev;
       obj.ino = st->st_ino;
-      found = hash_delete (fts->fts_cycle.ht, &obj);
+      found = hash_remove (fts->fts_cycle.ht, &obj);
       if (!found)
         abort ();
       free (found);
index 6b7b76a6c0e8d00fe781a99f52cbfacb7a74357a..2d64c82e59ec4d339b3445b4df64c9a50f021b7b 100644 (file)
@@ -1012,7 +1012,7 @@ hash_insert (Hash_table *table, void const *entry)
 }
 
 void *
-hash_delete (Hash_table *table, const void *entry)
+hash_remove (Hash_table *table, const void *entry)
 {
   void *data;
   struct hash_entry *bucket;
@@ -1071,6 +1071,12 @@ hash_delete (Hash_table *table, const void *entry)
   return data;
 }
 
+void *
+hash_delete (Hash_table *table, const void *entry)
+{
+  return hash_remove (table, entry);
+}
+
 /* Testing.  */
 
 #if TESTING
index a9d78c0fa20bea382cf700b3aee63d2296ab3492..e280adb13b90ea0a8b071b5feb774c6a9f9a12a6 100644 (file)
@@ -247,7 +247,12 @@ extern int hash_insert_if_absent (Hash_table *table, const void *entry,
 /* If ENTRY is already in the table, remove it and return the just-deleted
    data (the user may want to deallocate its storage).  If ENTRY is not in the
    table, don't modify the table and return NULL.  */
-extern void *hash_delete (Hash_table *table, const void *entry);
+extern void *hash_remove (Hash_table *table, const void *entry);
+
+/* Same as hash_remove.  This interface is deprecated.
+   FIXME: Remove in 2022.  */
+extern void *hash_delete (Hash_table *table, const void *entry)
+       _GL_ATTRIBUTE_DEPRECATED;
 
 # ifdef __cplusplus
 }
index 67d9519f552a920cdad0e3bfeb033bac53159fbb..6f1391c33f1330f505b416ccbb5b65794634044c 100644 (file)
@@ -132,10 +132,10 @@ main (int argc, char **argv)
         ASSERT (hash_get_entries (ht, buf, 5) == 3);
         ASSERT (STREQ (buf[0], "a") || STREQ (buf[0], "b") || STREQ (buf[0], "c"));
       }
-      ASSERT (hash_delete (ht, "a"));
-      ASSERT (hash_delete (ht, "a") == NULL);
-      ASSERT (hash_delete (ht, "b"));
-      ASSERT (hash_delete (ht, "c"));
+      ASSERT (hash_remove (ht, "a"));
+      ASSERT (hash_remove (ht, "a") == NULL);
+      ASSERT (hash_remove (ht, "b"));
+      ASSERT (hash_remove (ht, "c"));
 
       ASSERT (hash_rehash (ht, 47));
       ASSERT (hash_rehash (ht, 467));
@@ -246,7 +246,7 @@ main (int argc, char **argv)
                         /* empty */
                       }
                     ASSERT (p);
-                    v = hash_delete (ht, p);
+                    v = hash_remove (ht, p);
                     ASSERT (v);
                     free (v);
                   }