Opened 8 years ago

Last modified 2 years ago

#3876 new defect

Simplify format_win_commandline_argument() implementation.

Reported by: nickm Owned by: sjmurdoch
Priority: Very Low Milestone: Tor: unspecified
Component: Core Tor/Tor Version:
Severity: Normal Keywords: tor-relay easy refactoring
Cc: Actual Points:
Parent ID: Points: 1
Reviewer: Sponsor:


In format_win_commandline_argument(), it would be neat to skip the business of building a smartlist of char*, and just pre-allocate a guaranteed-to-be-long-enough string -- I think that strlen(arg)*2 + 3 would be long enough, since each character in the input turns into at most 2 characters in the output, and there are at most 3 characters of overhead: 1 for the nul-terminator, 2 for quotes.

This would actually use less RAM, since it only needs to allocate ~2 bytes per character, as opposed to 4 or 8 bytes per char*. Not that it matters -- we don't allocate a lot of these.

Child Tickets

Change History (5)

comment:1 Changed 7 years ago by nickm

Milestone: Tor: 0.2.3.x-finalTor: unspecified

comment:2 Changed 7 years ago by nickm

Keywords: tor-relay added

comment:3 Changed 7 years ago by nickm

Component: Tor RelayTor

comment:4 Changed 2 years ago by nickm

Keywords: easy added
Priority: MediumVery Low
Severity: Normal

comment:5 Changed 2 years ago by nickm

Keywords: refactoring added
Points: 1

And see also #22342

Note: See TracTickets for help on using tickets.