libctf: rename the type_mapping_key to type_key
authorNick Alcock <nick.alcock@oracle.com>
Thu, 4 Jun 2020 16:21:10 +0000 (17:21 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Wed, 22 Jul 2020 17:02:18 +0000 (18:02 +0100)
The name was just annoyingly long and I kept misspelling it.
It's also a bad name: it's not a mapping the type might be *used* in a
type mapping, but it is itself a representation of a type (a ctf_file_t
/ ctf_id_t pair), not of a mapping at all.

libctf/
* ctf-impl.h (ctf_link_type_mapping_key): Rename to...
(ctf_link_type_key): ... this, adjusting member prefixes to
match.
(ctf_hash_type_mapping_key): Rename to...
(ctf_hash_type_key): ... this.
(ctf_hash_eq_type_mapping_key): Rename to...
(ctf_hash_eq_type_key): ... this.
* ctf-hash.c (ctf_hash_type_mapping_key): Rename to...
(ctf_hash_type_key): ... this, and adjust for member name
changes.
(ctf_hash_eq_type_mapping_key): Rename to...
(ctf_hash_eq_type_key): ... this, and adjust for member name
changes.
* ctf-link.c (ctf_add_type_mapping): Adjust.  Note the lack of
need for out-of-memory checking in this code.
(ctf_type_mapping): Adjust.

libctf/ChangeLog
libctf/ctf-hash.c
libctf/ctf-impl.h
libctf/ctf-link.c

index c3e85a2ea44d1cb9be9fb1eeac7598ce87917d1f..f756fc4eeb71a9235b174a703e42406b09946059 100644 (file)
@@ -1,3 +1,22 @@
+2020-07-22  Nick Alcock  <nick.alcock@oracle.com>
+
+       * ctf-impl.h (ctf_link_type_mapping_key): Rename to...
+       (ctf_link_type_key): ... this, adjusting member prefixes to
+       match.
+       (ctf_hash_type_mapping_key): Rename to...
+       (ctf_hash_type_key): ... this.
+       (ctf_hash_eq_type_mapping_key): Rename to...
+       (ctf_hash_eq_type_key): ... this.
+       * ctf-hash.c (ctf_hash_type_mapping_key): Rename to...
+       (ctf_hash_type_key): ... this, and adjust for member name
+       changes.
+       (ctf_hash_eq_type_mapping_key): Rename to...
+       (ctf_hash_eq_type_key): ... this, and adjust for member name
+       changes.
+       * ctf-link.c (ctf_add_type_mapping): Adjust.  Note the lack of
+       need for out-of-memory checking in this code.
+       (ctf_type_mapping): Adjust.
+
 2020-07-22  Nick Alcock  <nick.alcock@oracle.com>
 
        configure.ac: Check for vasprintf.
index a026ef225da8b6779ca4a40c1742466d57920ec5..ed06f1f86a76f16e3a898510241d4b000f5ef72e 100644 (file)
@@ -94,26 +94,27 @@ ctf_hash_eq_string (const void *a, const void *b)
   return !strcmp((const char *) hep_a->key, (const char *) hep_b->key);
 }
 
-/* Hash a type_mapping_key.  */
+/* Hash a type_key.  */
 unsigned int
-ctf_hash_type_mapping_key (const void *ptr)
+ctf_hash_type_key (const void *ptr)
 {
   ctf_helem_t *hep = (ctf_helem_t *) ptr;
-  ctf_link_type_mapping_key_t *k = (ctf_link_type_mapping_key_t *) hep->key;
+  ctf_link_type_key_t *k = (ctf_link_type_key_t *) hep->key;
 
-  return htab_hash_pointer (k->cltm_fp) + 59 * htab_hash_pointer ((void *) k->cltm_idx);
+  return htab_hash_pointer (k->cltk_fp) + 59
+    * htab_hash_pointer ((void *) (uintptr_t) k->cltk_idx);
 }
 
 int
-ctf_hash_eq_type_mapping_key (const void *a, const void *b)
+ctf_hash_eq_type_key (const void *a, const void *b)
 {
   ctf_helem_t *hep_a = (ctf_helem_t *) a;
   ctf_helem_t *hep_b = (ctf_helem_t *) b;
-  ctf_link_type_mapping_key_t *key_a = (ctf_link_type_mapping_key_t *) hep_a->key;
-  ctf_link_type_mapping_key_t *key_b = (ctf_link_type_mapping_key_t *) hep_b->key;
+  ctf_link_type_key_t *key_a = (ctf_link_type_key_t *) hep_a->key;
+  ctf_link_type_key_t *key_b = (ctf_link_type_key_t *) hep_b->key;
 
-  return (key_a->cltm_fp == key_b->cltm_fp)
-    && (key_a->cltm_idx == key_b->cltm_idx);
+  return (key_a->cltk_fp == key_b->cltk_fp)
+    && (key_a->cltk_idx == key_b->cltk_idx);
 }
 
 
index 913a2647ed27f3d371d713fea77c7c4a4975fd35..b9d52af9d0e5c1cab5ff6777092a0e4634bad9d2 100644 (file)
@@ -232,16 +232,15 @@ typedef struct ctf_str_atom_ref
   uint32_t *caf_ref;           /* A single ref to this string.  */
 } ctf_str_atom_ref_t;
 
-/* The structure used as the key in a ctf_link_type_mapping, which lets the
-   linker machinery determine which type IDs on the input side of a link map to
-   which types on the output side.  (The value is a ctf_id_t: another
-   index, not a type.)  */
+/* The structure used as the key in a ctf_link_type_mapping.  The value is a
+   type index, not a type ID.  */
 
-typedef struct ctf_link_type_mapping_key
+typedef struct ctf_link_type_key
 {
-  ctf_file_t *cltm_fp;
-  ctf_id_t cltm_idx;
-} ctf_link_type_mapping_key_t;
+  ctf_file_t *cltk_fp;
+  ctf_id_t cltk_idx;
+} ctf_link_type_key_t;
+
 
 /* The ctf_file is the structure used to represent a CTF container to library
    clients, who see it only as an opaque pointer.  Modifications can therefore
@@ -421,12 +420,12 @@ extern ctf_file_t *ctf_get_dict (ctf_file_t *fp, ctf_id_t type);
 typedef unsigned int (*ctf_hash_fun) (const void *ptr);
 extern unsigned int ctf_hash_integer (const void *ptr);
 extern unsigned int ctf_hash_string (const void *ptr);
-extern unsigned int ctf_hash_type_mapping_key (const void *ptr);
+extern unsigned int ctf_hash_type_key (const void *ptr);
 
 typedef int (*ctf_hash_eq_fun) (const void *, const void *);
 extern int ctf_hash_eq_integer (const void *, const void *);
 extern int ctf_hash_eq_string (const void *, const void *);
-extern int ctf_hash_eq_type_mapping_key (const void *, const void *);
+extern int ctf_hash_eq_type_key (const void *, const void *);
 
 extern int ctf_dynset_eq_string (const void *, const void *);
 
index 31179ae13d7c2f349a6997baf79357bd6f8d86b1..c331fde35dc0492a78163a86c5c6d4142b31eed1 100644 (file)
@@ -53,22 +53,25 @@ ctf_add_type_mapping (ctf_file_t *src_fp, ctf_id_t src_type,
 
   if (dst_fp->ctf_link_type_mapping == NULL)
     {
-      ctf_hash_fun f = ctf_hash_type_mapping_key;
-      ctf_hash_eq_fun e = ctf_hash_eq_type_mapping_key;
+      ctf_hash_fun f = ctf_hash_type_key;
+      ctf_hash_eq_fun e = ctf_hash_eq_type_key;
 
       if ((dst_fp->ctf_link_type_mapping = ctf_dynhash_create (f, e, free,
                                                               NULL)) == NULL)
        return;
     }
 
-  ctf_link_type_mapping_key_t *key;
-  key = calloc (1, sizeof (struct ctf_link_type_mapping_key));
+  ctf_link_type_key_t *key;
+  key = calloc (1, sizeof (struct ctf_link_type_key));
   if (!key)
     return;
 
-  key->cltm_fp = src_fp;
-  key->cltm_idx = src_type;
+  key->cltk_fp = src_fp;
+  key->cltk_idx = src_type;
 
+  /* No OOM checking needed, because if this doesn't work the worst we'll do is
+     add a few more duplicate types (which will probably run out of memory
+     anyway).  */
   ctf_dynhash_insert (dst_fp->ctf_link_type_mapping, key,
                      (void *) (uintptr_t) dst_type);
 }
@@ -78,7 +81,7 @@ ctf_add_type_mapping (ctf_file_t *src_fp, ctf_id_t src_type,
 ctf_id_t
 ctf_type_mapping (ctf_file_t *src_fp, ctf_id_t src_type, ctf_file_t **dst_fp)
 {
-  ctf_link_type_mapping_key_t key;
+  ctf_link_type_key_t key;
   ctf_file_t *target_fp = *dst_fp;
   ctf_id_t dst_type = 0;
 
@@ -86,8 +89,8 @@ ctf_type_mapping (ctf_file_t *src_fp, ctf_id_t src_type, ctf_file_t **dst_fp)
     src_fp = src_fp->ctf_parent;
 
   src_type = LCTF_TYPE_TO_INDEX(src_fp, src_type);
-  key.cltm_fp = src_fp;
-  key.cltm_idx = src_type;
+  key.cltk_fp = src_fp;
+  key.cltk_idx = src_type;
 
   if (target_fp->ctf_link_type_mapping)
     dst_type = (uintptr_t) ctf_dynhash_lookup (target_fp->ctf_link_type_mapping,
This page took 0.029387 seconds and 4 git commands to generate.