[Vortex] [PATCH] guard win32 close calls [3/5]
Yourch, Chris
chris at replicus.com
Fri Feb 8 22:40:51 CET 2008
It looks like the macro is structure this way so an extra trailing
semi-colon won't cause trouble. If that is the case, structure the macro
as follows using the "do while loop" trick.
#define CLOSE_WIN32_HANDLE(X) \
do { \
if ((X) != INVALID_HANDLE_VALUE) \
CloseHandle(X); \
(X) = INVALID_HANDLE_VALUE; \
} while(0)
Also, and this is VERY important, an invalid handle, as returned from
CreateFile(), is an INVALID_HANDLE_VALUE and not a NULL. In addition, if
the handle is from FindFirstFile() then FindClose() should be called,
not CloseHandle().
What kinds of handles is this macro called for?
-----Original Message-----
From: vortex-bounces at lists.aspl.es [mailto:vortex-bounces at lists.aspl.es]
On Behalf Of Francis Brosnan Blazquez
Sent: Friday, February 08, 2008 8:54 AM
To: b.amiaux at ateme.com
Cc: Vortex
Subject: Re: [Vortex] [PATCH] guard win32 close calls [3/5]
Hi Benoit,
The patch looks good, but why don't directly check for X rather than
placing an empty branch "if (!X) {}". I'm missing something?
> +#define CLOSE_WIN32_HANDLE(X) if(!X) {} else{ CloseHandle(X); (X) =
> NULL; }
Cheers!
--
Francis Brosnan Blazquez <francis at aspl.es>
Advanced Software Production Line, S.L.
_______________________________________________
Vortex mailing list
Vortex at lists.aspl.es
http://lists.aspl.es/cgi-bin/mailman/listinfo/vortex
More information about the Vortex
mailing list