libctf: move string deduplication into ctf-archive

This means that any archive containing dicts can get its strings dedupped
together, rather than only those that are ctf_linked.

(For now, we are still constrained to ctf_linked archives, since fixing that
requires further changes to ctf_dedup_strings: but this gives us the first
half of what is necessary.)

libctf/
	* ctf-link.c (ctf_link_write): Move string dedup into...
	* ctf-archive.c (ctf_arc_preserialize): ... this new function.
	(ctf_arc_write_fd): Call it.
This commit is contained in:
Nick Alcock
2025-02-16 19:39:41 +00:00
parent 06f77d49f6
commit beccf36b88
4 changed files with 85 additions and 43 deletions

View File

@@ -152,7 +152,7 @@ static ctf_list_t open_errors;
open errors list if NULL): if ERR is nonzero it is the errno to report to the
debug stream instead of that recorded on fp. */
_libctf_printflike_ (4, 5)
extern void
void
ctf_err_warn (ctf_dict_t *fp, int is_warning, int err,
const char *format, ...)
{
@@ -203,6 +203,18 @@ ctf_err_warn_to_open (ctf_dict_t *fp)
ctf_list_splice (&open_errors, &fp->ctf_errs_warnings);
}
/* Copy all the errors/warnings from one fp to another one, and the error code
as well. */
void
ctf_err_copy (ctf_dict_t *dest, ctf_dict_t *src)
{
ctf_err_warning_t *cew;
for (cew = ctf_list_next (&src->ctf_errs_warnings); cew != NULL;
cew = ctf_list_next (cew))
ctf_err_warn (dest, cew->cew_is_warning, 0, cew->cew_text);
ctf_set_errno (dest, ctf_errno (src));
}
/* Error-warning reporting: an 'iterator' that returns errors and warnings from
the error/warning list, in order of emission. Errors and warnings are popped
after return: the caller must free the returned error-text pointer.