Bodo Moeller wrote:
> 
> Dr Stephen Henson <[EMAIL PROTECTED]>:
> 
> > getR looks a bit peculiar to me.
> 
> Yes, but the essential difference between XYZ_get_abc, XYZ_rget_abc
> and XYZ_iget_abc (for example X509_CTX_rget_chain, X509_CTX_iget_chain,
> X509_CTX_get_chain, except that we don't have all three names for this
> one) might be not visible enough.  I want the difference to stick out.
> I'm not really happy about X509_CTX_getR_chain either, but I haven't
> yet found anything really convincing.

In case anyone didn't see the original message in openssl-cvs I'll
summarise so some other people can give opinions or suggestions.

The basic problem is that connected with functions like XXX_get_YYY(),
XXX_set_YYY(), XXX_add_ZZZ() and others and their inconsistent
behaviour.

SSL_get_peer_cert_chain() and SSL_get_peer_certificate() are two
examples. 

SSL_get_peer_cert_chain() returns a STACK_OF(X509) which persists only
as long as the parent SSL structure does. So you can't use the stuff
after you free the SSL structure and you shouldn't free it yourself or
bad things will happen when you do SSL_free().

SSL_get_peer_certificate() on the other hand returns a certificate that
persists after the parent structure has been freed and if you don't free
it up you will get a memory leak.

The XXX_set_YYY() stuff is similar: sometimes it will "swallow" the
passed structure at other times it will take a copy or increase its
reference count.

These are just two examples and there is stuff all over the place like
this. The only way to be sure is to read the source code.

We can't really change the bahaviour so they all do the same because
this would break lots of existing code.

One solution I suggested is a naming convention where you precede the
word get/set/add etc with an 'i' (for internal) if it shouldn't be freed
and an 'r' (for reference) if it should be freed.

As you can see Bodo suggested placing an R or I after.

A third possibility is to use different words. Unfortunately some of
these have been grabbed already: 'extract' is used for various things
and appears synonymous with 'get'.

Once OpenSSL 0.9.5 is released with things following one or the other
convention it is all "cast in stone" and we are stuck with it.

So any preferences or alternative suggestions?

Steve.
-- 
Dr Stephen N. Henson.   http://www.drh-consultancy.demon.co.uk/
Personal Email: [EMAIL PROTECTED] 
Senior crypto engineer, Celo Communications: http://www.celocom.com/
Core developer of the   OpenSSL project: http://www.openssl.org/
Business Email: [EMAIL PROTECTED] PGP key: via homepage.

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to