[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: (ITS#4483) Confusion in freeing BerElement in abnormal conditions



ando@sys-net.it writes:
> I believe after this change the interface is much cleaner: if
> called with freeit set, ber_flush() always frees the BerElement,
> regardless of the return status.

That matches 'man ber_flush: "If the freeit parameter is non-zero,
the supplied ber will be freed after its contents have been flushed."
However...

> In case the caller wants to handle errors, it has to call ber_flush()
> with freeit unset, and free it explicitly in case of success or handle
> it otherwise.

It looks to be that you just described that the ber_flush() function has
a somewhat cumbersome interface.  Would it be useful to make the freeit
parameter should an enum?  Values:
{ 0 => don't free,
  some unlikely magic number => free unless error,
  1 => free (the "official" name & value for freeing),
  default => also free, for backwards compat }

-- 
Hallvard