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

Re: Conceptual Patch - Handle wrapper class

From: Oto BREZINA <otik_at_printflow.eu>
Date: Tue, 15 Mar 2011 09:25:59 +0100

On 2011-03-14 20:56, Stefan Küng wrote:
> On 12.03.2011 15:00, Oto BREZINA wrote:
>> Have examples if WinAPI (one we talk about here) method addes in Win32
>> with error value not NULL ?
>> 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.
> Not really, no. But I've never heard that INVALID_HANDLE_VALUE is for
> compatibility with 16-bit windows.
Here is one reference however it may reflect opinon of author ...

some mail-list talk about this
> There's already a CHandle class:
> http://msdn.microsoft.com/en-US/library/80w70bhc%28v=VS.100%29.aspx
Nice - I don't have VC so did not know. I like handle NULL as Invalid
handle more then INVALID_HANdLE_VALUE (-1), simplier test (even not
much). But that would break lot of your code.
This class don't help with dealing with INVALID_HANDLE_VALUE as they
state: If you call an API which can return INVALID_HANDLE_VALUE, you
should check for this value before ... and instead pass NULL.
ref: http://msdn.microsoft.com/en-US/library/5fc6ft2t.aspx

Using class interface I suggested:
  - you can handle NULL as well as INVALD_HANDLE_VALUE as invalid
handle. (not in VC CHandle)
  - HANDLE would be closed automaticaly (VC CHandle handle this as well)
  - have interface to check valid value without knowing what value it
invalid (not in VC, but not urgent, but MAY improve readability for new
  - have HANDLE operatator = (VC too)

  - can be extended with refcounting to simplify determining what code
should close handle. BTW: is TSVN multi thread?

If you get interested, we may either derive CHandle or start new one.
CAutoHandle ? CSharedHandle (with refcounting)?

> Stefan

Oto BREZINA, Printflow s.r.o., EU
To unsubscribe from this discussion, e-mail: [dev-unsubscribe_at_tortoisesvn.tigris.org].
Received on 2011-03-15 09:34:21 CET

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