libctf: rip out dead code handling typedefs with no name
[deliverable/binutils-gdb.git] / libctf / ctf-open.c
index 7816fd0af102ccbfa1963fd9b0ce225bc08f1f06..67d9f84c361820ced0bb2865ee2ffcccb8657ae8 100644 (file)
@@ -1,5 +1,5 @@
 /* Opening CTF files.
-   Copyright (C) 2019-2020 Free Software Foundation, Inc.
+   Copyright (C) 2019-2021 Free Software Foundation, Inc.
 
    This file is part of libctf.
 
@@ -683,7 +683,7 @@ init_types (ctf_dict_t *fp, ctf_header_t *cth)
 
   unsigned long pop[CTF_K_MAX + 1] = { 0 };
   const ctf_type_t *tp;
-  uint32_t id, dst;
+  uint32_t id;
   uint32_t *xp;
 
   /* We determine whether the dict is a child or a parent based on the value of
@@ -953,25 +953,6 @@ init_types (ctf_dict_t *fp, ctf_header_t *cth)
   ctf_dprintf ("%u base type names hashed\n",
               ctf_hash_size (fp->ctf_names.ctn_readonly));
 
-  /* Make an additional pass through the pointer table to find pointers that
-     point to anonymous typedef nodes.  If we find one, modify the pointer table
-     so that the pointer is also known to point to the node that is referenced
-     by the anonymous typedef node.  */
-
-  for (id = 1; id <= fp->ctf_typemax; id++)
-    {
-      if ((dst = fp->ctf_ptrtab[id]) != 0)
-       {
-         tp = LCTF_INDEX_TO_TYPEPTR (fp, id);
-
-         if (LCTF_INFO_KIND (fp, tp->ctt_info) == CTF_K_TYPEDEF
-             && strcmp (ctf_strptr (fp, tp->ctt_name), "") == 0
-             && LCTF_TYPE_ISCHILD (fp, tp->ctt_type) == child
-             && LCTF_TYPE_TO_INDEX (fp, tp->ctt_type) <= fp->ctf_typemax)
-             fp->ctf_ptrtab[LCTF_TYPE_TO_INDEX (fp, tp->ctt_type)] = dst;
-       }
-    }
-
   return 0;
 }
 
@@ -1806,6 +1787,7 @@ ctf_dict_close (ctf_dict_t *fp)
   free (fp->ctf_sxlate);
   free (fp->ctf_txlate);
   free (fp->ctf_ptrtab);
+  free (fp->ctf_pptrtab);
 
   free (fp->ctf_header);
   free (fp);
@@ -1931,7 +1913,8 @@ ctf_cuname_set (ctf_dict_t *fp, const char *name)
 
 /* Import the types from the specified parent dict by storing a pointer to it in
    ctf_parent and incrementing its reference count.  Only one parent is allowed:
-   if a parent already exists, it is replaced by the new parent.  */
+   if a parent already exists, it is replaced by the new parent.  The pptrtab
+   is wiped, and will be refreshed by the next ctf_lookup_by_name call.  */
 int
 ctf_import (ctf_dict_t *fp, ctf_dict_t *pfp)
 {
@@ -1945,6 +1928,11 @@ ctf_import (ctf_dict_t *fp, ctf_dict_t *pfp)
     ctf_dict_close (fp->ctf_parent);
   fp->ctf_parent = NULL;
 
+  free (fp->ctf_pptrtab);
+  fp->ctf_pptrtab = NULL;
+  fp->ctf_pptrtab_len = 0;
+  fp->ctf_pptrtab_typemax = 0;
+
   if (pfp != NULL)
     {
       int err;
@@ -1979,6 +1967,10 @@ ctf_import_unref (ctf_dict_t *fp, ctf_dict_t *pfp)
     ctf_dict_close (fp->ctf_parent);
   fp->ctf_parent = NULL;
 
+  free (fp->ctf_pptrtab);
+  fp->ctf_pptrtab = NULL;
+  fp->ctf_pptrtab_len = 0;
+  fp->ctf_pptrtab_typemax = 0;
   if (pfp != NULL)
     {
       int err;
This page took 0.02496 seconds and 4 git commands to generate.