Wide-string Functions: Double Casting

David Laight david at l8s.co.uk
Mon Aug 7 16:38:44 CDT 2006


On Mon, Aug 07, 2006 at 09:54:20PM +0100, Andrew Talbot wrote:
> would like to submit a patch that, for example, changes strchrW() to:
> 
> extern inline WCHAR *strrchrW( const WCHAR *str, WCHAR ch )
> {
>     WCHAR *ret = NULL;
>     do { if (*str == ch) ret = (WCHAR *)(size_t)str; } while (*str++);
>     return ret;
> }

why not just have:

extern inline void *__deconst(const void *v)
{
	return (char *)0 + ((const char *)v - (const char *)0));
}

Then the code above could be:
extern inline WCHAR *strrchrW( const WCHAR *str, WCHAR ch )
{
	do { if (*str == ch) return __deconst(str); } while (*str++);
	return 0;
}

	David

-- 
David Laight: david at l8s.co.uk



More information about the wine-devel mailing list