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

Re: AW: Conceptual Patch - Handle wrapper class

From: Stefan Küng <tortoisesvn_at_gmail.com>
Date: Tue, 15 Mar 2011 20:19:11 +0100

On 15.03.2011 10:48, Oto BREZINA wrote:
> Dear Jens,
> On 2011-03-15 10:23, Jens Geyer wrote:
>>> I just read some articels about NULL vs. INVALID_HANDLER_VALUE and
>>> author states that all new (not existing in WIN16) methods are NULL on
>>> error.
>> The author is probably wrong here.
>> If in doubt, which values are returned, I would suggest to ask MSDN about that.
>> Although there are also quite a few errors in there, this is the reference I would start with.

I doubt that Raymond Chen is ever wrong when it comes to the Windows API :)

But the blog post indicates that while INVALID_HANDLE_VALUE has its
origins in win16, even new APIs use it: "[...]whenever a new function
got added, it was a bit of a toss-up whether the new function returned

> I use MSDN as first point to get info about parameters and returned
> values of course. If INVALID_HANDLE_VALUE is just for compatibility with
> win16 code or not, is only side question.
> Main questions (already anwsered) were:
> Can be NULL valid? Can be INVALID_HANDLE_VALUE valid?

From the blog post you linked before:

"Fourth, you have to be particularly careful with the
INVALID_HANDLE_VALUE value: By coincidence, the value
INVALID_HANDLE_VALUE happens to be numerically equal to the
pseudohandle returned by GetCurrentProcess(). Many kernel functions
accept pseudohandles [...]"

So INVALID_HANDLE_VALUE *can* be a valid handle (a pseudo handle, but
still a valid one). And "many kernel functions accept pseudohandles"
indicates that this is not just one API but several.

So IMHO while the idea of a wrapper class is good, it is dangerous.
I'd like to keep the code as is, using the handles for each API
separately according to its documentation.


  oo  // \\      "De Chelonian Mobile"
 (_,\/ \_/ \     TortoiseSVN
   \ \_/_\_/>    The coolest Interface to (Sub)Version Control
   /_/   \_\     http://tortoisesvn.net
To unsubscribe from this discussion, e-mail: [dev-unsubscribe_at_tortoisesvn.tigris.org].
Received on 2011-03-15 20:19:37 CET

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.