On 28.12.2018 11:19, Branko Čibej wrote:
> On 28.12.2018 11:05, Bert Huijben wrote:
>> +svn_error_t *
>> +svn_error__malfunction_f(svn_boolean_t can_return,
>> + const char *file, int line,
>> + const char *fmt, ...)
>> +{
>> + apr_pool_t *pool = svn_pool_create(NULL);
>> + va_list ap;
>> + const char *expr;
>> +
>> + va_start(ap, fmt);
>> + expr = apr_pvsprintf(pool, fmt, ap);
>> + va_end(ap);
>> + return malfunction_handler(can_return, file, line, expr);
>> +}
>> +
>>
>> Can we somehow use a smarter pool (perhaps just require passing an existing
>> scratch pool as some similar apr apis do). Some library users do use the
>> can_return feature and/or exception handling and we would introduce a minor
>> memory leak.
> We'd have to somehow tweak the malfunction_handler to create its own
> svn_error_t* from the provided pool.
>
> Another option is to check if can_return is set, and only then, call the
> malfunction_handler first and then change the message stored in the
> returned svn_error_t, using the error pool for formatting.
... but that might cause the expression to not be dispayed to the user ...
Received on 2018-12-28 11:21:14 CET