Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • Tor Tor
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 327
    • Issues 327
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 31
    • Merge requests 31
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • The Tor Project
  • Core
  • TorTor
  • Issues
  • #20048
Closed
Open
Issue created Sep 01, 2016 by George Kadianakis@asnContributor

Introduce `smartlist_add_strdup()` function

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!

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking