From: Julian Seward Date: Fri, 24 Aug 2012 14:44:27 +0000 (+0000) Subject: Implement a wrapper for wcslen on Linux, assuming that X-Git-Tag: svn/VALGRIND_3_9_0~747 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec3a16088b1992e3ab3ca3f2cb93adeacc247064;p=thirdparty%2Fvalgrind.git Implement a wrapper for wcslen on Linux, assuming that sizeof(wchar_t) == 4, which I believe to be true on both Linux and MacOSX. Fixes #298281. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12893 --- diff --git a/memcheck/mc_replace_strmem.c b/memcheck/mc_replace_strmem.c index 6c0e08b8e2..b5b6b5d680 100644 --- a/memcheck/mc_replace_strmem.c +++ b/memcheck/mc_replace_strmem.c @@ -96,6 +96,7 @@ 20340 STRSPN 20350 STRCASESTR 20360 MEMRCHR + 20370 WCSLEN */ @@ -1543,6 +1544,32 @@ static inline void my_exit ( int x ) #endif +/*---------------------- wcslen ----------------------*/ + +// This is a wchar_t equivalent to strlen. Unfortunately +// we don't have wchar_t available here, but it looks like +// a 32 bit int on Linux. I don't know if that is also +// valid on MacOSX. + +#define WCSLEN(soname, fnname) \ + SizeT VG_REPLACE_FUNCTION_EZU(20370,soname,fnname) \ + ( const UInt* str ); \ + SizeT VG_REPLACE_FUNCTION_EZU(20370,soname,fnname) \ + ( const UInt* str ) \ + { \ + SizeT i = 0; \ + while (str[i] != 0) i++; \ + return i; \ + } + +#if defined(VGO_linux) + WCSLEN(VG_Z_LIBC_SONAME, wcslen) + +#elif defined(VGO_darwin) + +#endif + + /*------------------------------------------------------------*/ /*--- Improve definedness checking of process environment ---*/ /*------------------------------------------------------------*/