Kaydet (Commit) f5585675 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

loplugin:redundantcast: Work around OS X memchr bug

...where in C++ memchr does not have exactly the two overloads

  void const * memchr(void const *, int, size_t)
  void * memchr(void *, int, size_t)

but rather the C

  void * memchr(void const *, int, size_t)

shining through (see bugreport.apple.com issue 21128245 "non-conforming memchr
in C++"), which gets in the way of the upcoming improved redundant const_cast
check in loplugin:redundantcast.

Change-Id: I7001e74e03429ef23682d52da28fca435130d775
üst 9155210d
......@@ -26,7 +26,7 @@
#include <cassert>
#include <limits>
#include <string.h>
#include <cstring>
#include <wchar.h>
#include <sal/log.hxx>
#include <rtl/character.hxx>
......@@ -387,7 +387,7 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( indexOfChar_WithLength )( const IMPL_RTL_ST
// assert(nLen >= 0);
#if !IMPL_RTL_IS_USTRING
// take advantage of builtin optimisations
IMPL_RTL_STRCODE* p = static_cast<IMPL_RTL_STRCODE*>(const_cast<void *>(memchr(pStr, c, nLen)));
IMPL_RTL_STRCODE* p = static_cast<IMPL_RTL_STRCODE*>(std::memchr(const_cast<IMPL_RTL_STRCODE *>(pStr), c, nLen));
return p ? p - pStr : -1;
#else
const IMPL_RTL_STRCODE* pTempStr = pStr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment