On Thu, 2021-08-19 at 11:30 -0600, Martin Sebor via Gcc-patches wrote: > Hey Aldy & Andrew, > > I introduced a leak by calling enable_ranger() without pairing it > with one to disable_ranger() on the same function (PR 101984). > I didn't realize (or look to see) that enable_ranger() dynamically > allocates memory. > > The patch below adds comments to make it clear that the calls need > to be paired. That seems obvious now but wasn't before from just > the function names. So I'm wondering if we might want to rename > them to make it more obvious that the former involves allocating > memory that must be explicitly deallocated. > > If you agree, names along the following lines would make this > clearer (to me, anyway) but I'm open to others: > > gimple_ranger *set_new_ranger (function *); > void release_ranger (function *);
Could an RAII class help here, to make the aquire/release pairing more automatic? Dave