libctf: rename the type_mapping_key to type_key
[deliverable/binutils-gdb.git] / libctf / ctf-link.c
index e2a034841153b39781c5b9a405c792e4f06d3789..c331fde35dc0492a78163a86c5c6d4142b31eed1 100644 (file)
@@ -1,5 +1,5 @@
 /* CTF linking.
-   Copyright (C) 2019 Free Software Foundation, Inc.
+   Copyright (C) 2019-2020 Free Software Foundation, Inc.
 
    This file is part of libctf.
 
@@ -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,
@@ -639,7 +642,7 @@ ctf_link_intern_extern_string (void *key _libctf_unused_, void *value,
   ctf_link_out_string_cb_arg_t *arg = (ctf_link_out_string_cb_arg_t *) arg_;
 
   fp->ctf_flags |= LCTF_DIRTY;
-  if (ctf_str_add_external (fp, arg->str, arg->offset) == NULL)
+  if (!ctf_str_add_external (fp, arg->str, arg->offset))
     arg->err = ENOMEM;
 }
 
@@ -662,7 +665,7 @@ ctf_link_add_strtab (ctf_file_t *fp, ctf_link_strtab_string_f *add_string,
       ctf_link_out_string_cb_arg_t iter_arg = { str, offset, 0 };
 
       fp->ctf_flags |= LCTF_DIRTY;
-      if (ctf_str_add_external (fp, str, offset) == NULL)
+      if (!ctf_str_add_external (fp, str, offset))
        err = ENOMEM;
 
       ctf_dynhash_iter (fp->ctf_link_outputs, ctf_link_intern_extern_string,
@@ -693,8 +696,7 @@ typedef struct ctf_name_list_accum_cb_arg
   size_t ndynames;
 } ctf_name_list_accum_cb_arg_t;
 
-/* Accumulate the names and a count of the names in the link output hash,
-   and run ctf_update() on them to generate them.  */
+/* Accumulate the names and a count of the names in the link output hash.  */
 static void
 ctf_accumulate_archive_names (void *key, void *value, void *arg_)
 {
@@ -703,13 +705,6 @@ ctf_accumulate_archive_names (void *key, void *value, void *arg_)
   char **names;
   ctf_file_t **files;
   ctf_name_list_accum_cb_arg_t *arg = (ctf_name_list_accum_cb_arg_t *) arg_;
-  int err;
-
-  if ((err = ctf_update (fp)) < 0)
-    {
-      ctf_set_errno (arg->fp, ctf_errno (fp));
-      return;
-    }
 
   if ((names = realloc (arg->names, sizeof (char *) * ++(arg->i))) == NULL)
     {
@@ -788,12 +783,6 @@ ctf_link_write (ctf_file_t *fp, size_t *size, size_t threshold)
   memset (&arg, 0, sizeof (ctf_name_list_accum_cb_arg_t));
   arg.fp = fp;
 
-  if (ctf_update (fp) < 0)
-    {
-      errloc = "CTF file construction";
-      goto err;
-    }
-
   if (fp->ctf_link_outputs)
     {
       ctf_dynhash_iter (fp->ctf_link_outputs, ctf_accumulate_archive_names, &arg);
This page took 0.024611 seconds and 4 git commands to generate.