libctf: eliminate dtd_u, part 2: arrays

This is even simpler than ints, floats and slices, with the only extra
complication being the need to manually transfer the array parameter in
the rarely-used function ctf_set_array.  (Arrays are unique in libctf in
that they can be modified post facto, not just created and appended to.
I'm not sure why they got this exemption, but it's easy to maintain.)

libctf/ChangeLog
2021-03-18  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-impl.h (ctf_dtdef_t) <dtd_u.dtu_arr>: Remove.
	* ctf-create.c (ctf_add_array): Use the dtd_vlen, not dtu_arr.
	(ctf_set_array): Likewise.
	* ctf-serialize.c (ctf_emit_type_sect): Just copy the dtd_vlen.
	* ctf-types.c (ctf_array_info): Just use the vlen.
This commit is contained in:
Nick Alcock 2021-03-18 12:37:52 +00:00
parent 7879dd88ef
commit 534444b1ee
5 changed files with 27 additions and 16 deletions

View file

@ -1520,14 +1520,12 @@ ctf_array_info (ctf_dict_t *fp, ctf_id_t type, ctf_arinfo_t *arp)
return (ctf_set_errno (ofp, ECTF_NOTARRAY));
if ((dtd = ctf_dynamic_type (ofp, type)) != NULL)
ap = (const ctf_array_t *) dtd->dtd_vlen;
else
{
*arp = dtd->dtd_u.dtu_arr;
return 0;
ctf_get_ctt_size (fp, tp, NULL, &increment);
ap = (const ctf_array_t *) ((uintptr_t) tp + increment);
}
(void) ctf_get_ctt_size (fp, tp, NULL, &increment);
ap = (const ctf_array_t *) ((uintptr_t) tp + increment);
arp->ctr_contents = ap->cta_contents;
arp->ctr_index = ap->cta_index;
arp->ctr_nelems = ap->cta_nelems;