[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 20:03:59 UTC 2017


#24337: Every _free() function should be a macro that sets the corresponding
pointer to NULL.
----------------------------------------------+----------------------------
 Reporter:  nickm                             |          Owner:  nickm
     Type:  enhancement                       |         Status:
                                              |  merge_ready
 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:  dgoulet                           |        Sponsor:
                                              |  Sponsor8-can
----------------------------------------------+----------------------------

Comment (by nickm):

 I don't think that macro example would work -- putting FREE_AND_NULL in an
 inline function would make it have no effect on the varfiable the functio
 is called on -- only __obj would get set to NULL.

 What you'd need here is some way do say
 {{{
 #define DECL_FREE(name, typename)                 \
   void name##_(typename *__obj);                  \
   #define name(obj) FREE_AND_NULL(typename, name##_, (obj))
 }}}
 but you can't do that in C.

 Squashed and merged.  Some conflicts resolved in "5ee0cccd49e57fad8c81".

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


More information about the tor-bugs mailing list