On 12/05/2010 02:36 AM, Alex Rousskov wrote:
> On 12/04/2010 08:38 AM, Henrik Nordström wrote:
>> fre 2010-12-03 klockan 19:11 +0200 skrev Tsantilas Christos:
>
>>> "../../../src/ssl/gadgets.h", line 38: Error, temargnoval: Template
>>> parameter DeAllocator requires an expression of type void(*)(x509_st*).
>
>>> The only way I found to solve the above is to define C++ wrappers
>>> functions for X509_free, EVP_PKEY_free, BIG_NUM_free etc (~ 10 wrapper
>>> functions)
>
>
>> extern "C" in the DeAllocator declaration should be sufficient, maybe
>> "hidden" in an typedef for clarity.
>
> extern "C" is not ideal because it would limit TidyPointer to C
> de-allocators. Besides, it is illegal in template parameter declarations:
>
> error: storage class specifiers invalid in parameter declarations
>
> I think our options are:
>
> (a) wrap X509_free and friends into their C++ versions. It may be
> possible to do that with a single macro if inline functions can have
> storage class specifiers:
>
> #define CtoCpp1(function, argument) \
> extern "C++" inline void function ## _cpp(argument a) { \
> function(a); \
> }
>
> CtoCpp1(X509_free, X509*);
>
> typedef TidyPointer<X509, X509_free_cpp> X509_Pointer;
>
>
> (b) Change TidyPointer to use a class instead of a function pointer as
> the second parameter (this is what STL does; see std::find). However,
> this would require specifying deallocators when declaring variables
> rather than at typedef time so it would lead to uglier code or more
> #defines and similar hacks.
>
> Sounds like (a) is the way to go. Any better ideas?
I will commit a patch with the (a).
>
> BTW, Christos, you do not need the deAllocator member. Just use the
> template parameter.
Oops. I did not like the idea to use wrapper functions (extra function
calls without reason) and inline functions can not be used here because
of the deAllocator member pointer.
But yes this pointer does not needed ....
>
> HTH,
>
> Alex.
>
Received on Mon Dec 06 2010 - 11:41:17 MST
This archive was generated by hypermail 2.2.0 : Mon Dec 06 2010 - 12:00:05 MST