[tor-bugs] #22342 [Core Tor/Tor]: Add a nice append-only stringbuffer, and refactor code to use it
Tor Bug Tracker & Wiki
blackhole at torproject.org
Tue May 23 13:57:56 UTC 2017
#22342: Add a nice append-only stringbuffer, and refactor code to use it
------------------------------+------------------------------
Reporter: nickm | Owner:
Type: defect | Status: new
Priority: Medium | Milestone: Tor: unspecified
Component: Core Tor/Tor | Version:
Severity: Normal | Keywords: intro
Actual Points: | Parent ID:
Points: | Reviewer:
Sponsor: |
------------------------------+------------------------------
Right now we have 2.5 strategies for building strings out of pieces:
1a) Sometimes, we use a stack-allocated buffer, and a pointer into that
buffer, and we write into that buffer using tor_snprintf and strlcpy and
friends.
1b) Sometimes we do the same with a heap-allocated buffer.
2) Sometimes we allocate a smartlist full of little strings, and use
smartlist_join_strings() to turn it into one big string.
Both of these methods are cumbersome and at least somewhat inefficient.
It would be better to have something that managed the buffer size, and
supported commands like "extend with snprintf" or "extend with string".
Calling this "intro" because it doesn't require extensive knowledge of
Tor; but it isn't a small task to do it right. This is something where
we'd want to optimize for efficiency... though in the short run, we might
just do it as a wrapper around smartlist_t and smartlist_join_strings().
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/22342>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tor-bugs
mailing list