[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-bugs] #8308 [Tor]: Use smartlist-of-strings rather than preallocated-charbuf for more directory stuff
#8308: Use smartlist-of-strings rather than preallocated-charbuf for more
directory stuff
--------------------------------+-------------------------------------------
Reporter: nickm | Owner:
Type: defect | Status: new
Priority: normal | Milestone: Tor: 0.2.4.x-final
Component: Tor | Version:
Keywords: tor-auth tor-relay | Parent:
Points: | Actualpoints:
--------------------------------+-------------------------------------------
In too many places, we have code that looks like this:
{{{
r = tor_snprintf(s+written, maxlen-s, "foo %s %s\nbar %s\n", baz, qux,
quuz);
if (r<0) {
goto err;
}
written += n;
...
return buf;
}}}
or other variants on the theme. This is much easier phrased as
{{{
smartlist_add_asprintf(chunks, "foo %s %s\nbar %s\n", baz, qux, quuz);
...
return smartlist_join_strings(chunks, "", ...);
}}}
Making this change will remove a bunch of boilerplate, eliminate some risk
of cut-and-paste errors, make a large class of "didn't allocate enough"
bugs impossible, and generally make our code easier to read.
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/8308>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs