[tor-bugs] #20048 [Core Tor/Tor]: Introduce `smartlist_add_strdup()` function
Tor Bug Tracker & Wiki
blackhole at torproject.org
Thu Sep 1 13:18:58 UTC 2016
#20048: Introduce `smartlist_add_strdup()` function
------------------------------+--------------------------
Reporter: asn | Owner:
Type: task | Status: new
Priority: Medium | Milestone: Tor: 0.2.???
Component: Core Tor/Tor | Version:
Severity: Normal | Keywords: easy
Actual Points: | Parent ID:
Points: 0.3 | Reviewer:
Sponsor: |
------------------------------+--------------------------
There are many places in the code (and the tests) where we do the
following pattern:
`smartlist_add(sl, tor_strdup(str))`
Some examples:
{{{
routerparse.c: smartlist_add(ns->package_lines,
tor_strdup(t->args[0])));
routerparse.c: smartlist_add(ns->known_flags,
tor_strdup(tok->args[i]));
routerparse.c: smartlist_add(ns->net_params,
tor_strdup(tok->args[i]));
routerparse.c: smartlist_add(ns->weight_params,
tor_strdup(tok->args[i]));
routerparse.c: smartlist_add(md->family, tor_strdup(tok->args[i]));
routerset.c: smartlist_add(set->country_names, tor_strdup("??"));
routerset.c: smartlist_add(set->list, tor_strdup("{??}"));
routerset.c: smartlist_add(set->country_names, tor_strdup("a1"));
routerset.c: smartlist_add(set->list, tor_strdup("{a1}"));
}}}
One could imagine a `smartlist_add_strdup()` function that does this for
the developer, and can be used in places where this pattern is used
repeatedly.
It might simplify logic in a few places, or maybe it will confuse peole
who grep for `tor_strdup` searching for allocations.
If people think this is worth doing, let's do it!
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/20048>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tor-bugs
mailing list