/* 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.
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
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;
}
free (fp->ctf_sxlate);
free (fp->ctf_txlate);
free (fp->ctf_ptrtab);
+ free (fp->ctf_pptrtab);
free (fp->ctf_header);
free (fp);
/* 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)
{
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;
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;