[tor-bugs] #24337 [Core Tor/Tor]: Every _free() function should be a macro that sets the corresponding pointer to NULL.

Tor Bug Tracker & Wiki blackhole at torproject.org
Fri Dec 8 14:13:09 UTC 2017


#24337: Every _free() function should be a macro that sets the corresponding
pointer to NULL.
----------------------------------------------+----------------------------
 Reporter:  nickm                             |          Owner:  nickm
     Type:  enhancement                       |         Status:
                                              |  needs_revision
 Priority:  Medium                            |      Milestone:  Tor:
                                              |  0.3.3.x-final
Component:  Core Tor/Tor                      |        Version:
 Severity:  Normal                            |     Resolution:
 Keywords:  review-group-26, review-group-27  |  Actual Points:
Parent ID:                                    |         Points:
 Reviewer:                                    |        Sponsor:
                                              |  Sponsor8-can
----------------------------------------------+----------------------------
Changes (by dgoulet):

 * status:  needs_review => needs_revision


Comment:

 I like it! Although, did you do that by hand or with a script? I'm asking
 because I see some indentation issue when it goes to 3 lines which should
 be not that complicated to fix with a script?

 {{{
 +#define service_intro_point_free(ip)                            \
 +  FREE_AND_NULL(hs_service_intro_point_t,             \
 +                          service_intro_point_free_, (ip))
 }}}

 Ideally, we would like to have them lined up:

 {{{
 +#define service_intro_point_free(ip)              \
 +  FREE_AND_NULL(hs_service_intro_point_t,         \
 +                service_intro_point_free_, (ip))
 }}}

 Also, if we could have a note in our CodingStandards.md about this
 template, it would be grand!

 Finally, correct me if I'm wrong, but this also *only* applies to non-
 static (public) free functions so if we merge this, we'll still have a
 series of static functions that don't do this "free and null" dance. Can
 we think of something to fix that? I mean, seems that we can only enforce
 this template to our public functions but nothing within a C code file
 unless we make all those symbols public and I'm not too keen about that
 :S.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/24337#comment:18>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list