diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-09-16 10:52:25 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-09-16 12:18:33 +0000 |
commit | c480677f5f654ada532dfba21e3d34718c977131 (patch) | |
tree | 96e7993d323379d1492cd8db4b8b717c6db806e4 /binaryurp | |
parent | 77cf4acc2765e43e3289fc9331111fb510c9a30c (diff) |
In binaryurp, fix change from rtl_copyMemory to memcpy
...done in 36a2db3722b79ed3df075d7f3fa77fb761bcf5a4 "Replace usage of
rtl_*Memory with equivalent from string.h"
Change-Id: I068feab3140cdcb34ea8c80e273ea2761f0efb7f
Reviewed-on: https://gerrit.libreoffice.org/28941
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'binaryurp')
-rw-r--r-- | binaryurp/source/writer.cxx | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/binaryurp/source/writer.cxx b/binaryurp/source/writer.cxx index 7558f8296024..54373d1807f7 100644 --- a/binaryurp/source/writer.cxx +++ b/binaryurp/source/writer.cxx @@ -19,9 +19,12 @@ #include "sal/config.h" +#include <cassert> +#include <cstddef> +#include <cstring> #include <exception> +#include <limits> #include <vector> -#include <string.h> #include "com/sun/star/connection/XConnection.hpp" #include "com/sun/star/lang/WrappedTargetRuntimeException.hpp" @@ -411,18 +414,17 @@ void Writer::sendMessage(std::vector< unsigned char > const & buffer) { OSL_ASSERT(!buffer.empty()); unsigned char const * p = &buffer[0]; std::vector< unsigned char >::size_type n = buffer.size(); - OSL_ASSERT(header.size() <= SAL_MAX_INT32 && SAL_MAX_INT32 <= SAL_MAX_SIZE); - sal_Size k = SAL_MAX_INT32 - header.size(); + OSL_ASSERT(header.size() <= SAL_MAX_INT32); + /*static_*/assert(SAL_MAX_INT32 <= std::numeric_limits<std::size_t>::max()); + std::size_t k = SAL_MAX_INT32 - header.size(); if (n < k) { - k = static_cast< sal_Size >(n); + k = n; } - css::uno::Sequence< sal_Int8 > s( - static_cast< sal_Int32 >(header.size() + k)); + css::uno::Sequence<sal_Int8> s(header.size() + k); OSL_ASSERT(!header.empty()); - memcpy( - s.getArray(), &header[0], static_cast< sal_Size >(header.size())); + std::memcpy(s.getArray(), &header[0], header.size()); for (;;) { - memcpy(s.getArray() + s.getLength() - k, p, k); + std::memcpy(s.getArray() + s.getLength() - k, p, k); try { bridge_->getConnection()->write(s); } catch (const css::io::IOException & e) { @@ -431,14 +433,14 @@ void Writer::sendMessage(std::vector< unsigned char > const & buffer) { "Binary URP write raised IO exception: " + e.Message, css::uno::Reference< css::uno::XInterface >(), exc); } - n = static_cast< std::vector< unsigned char >::size_type >(n - k); + n -= k; if (n == 0) { break; } p += k; k = SAL_MAX_INT32; if (n < k) { - k = static_cast< sal_Size >(n); + k = n; } s.realloc(k); } |