[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r1803143 - in /subversion/trunk/subversion: include/ libsvn_delta/ libsvn_ra_serf/ mod_dav_svn/

From: Evgeny Kotkov <evgeny.kotkov_at_visualsvn.com>
Date: Fri, 1 Sep 2017 17:13:10 +0300

Daniel Shahaf <d.s_at_daniel.shahaf.name> writes:

> I'm not sure I'm getting through here.
> The note does say "Don't allocate one of these yourself" but in the
> second sentence implies that the reason for this is that if you allocate
> it yourself and don't initialize all pointer-to-function members,
> Trouble will ensue. Therefore, the note could be construed as meaning
> that it is okay to allocate one of these yourself if you take care to
> initialize all pointer members.
> In other words: the comment could have been interpreted as a piece
> of advice --- "it is more robust to use _default_editor() than to allocate
> with malloc" --- as opposed to a blanket prohibition on allocating this
> struct type with malloc.
> (If one uses malloc and doesn't initialize all pointers, the result
> would be that an uninitialized pointer-to-function struct member is
> dereferenced.)
> In contrast, most of our other structs explicitly say that "Don't
> allocate yourself because we may add new fields in the future". This
> struct does not give that reason.
> Makes sense?
> I suppose can just add an API erratum and/or release notes entry about this.

I think that the important thing about this documentation is that it
states that:

 (1) The API user shouldn't try to allocate the struct himself.

 (2) A constructor such as svn_delta_default_editor() should *always*
     be used.

To my mind, the current statement is clear and it is not possible to
interpret it as if it's allowed to malloc() the struct and initialize it

My opinion here is that neither the API erratum nor including this in the
release notes are required, and doing so would just unnecessarily restate
the information that's already available.

Also, I am not against the idea of tweaking the note by saying something
like "...because we may add new fields in the future", but I don't think
that it is required either. (In other words, I am +0 to that.)

Evgeny Kotkov
Received on 2017-09-01 16:13:40 CEST

This is an archived mail posted to the Subversion Dev mailing list.