summaryrefslogtreecommitdiff
path: root/binaryurp/source/writer.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'binaryurp/source/writer.cxx')
-rw-r--r--binaryurp/source/writer.cxx24
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);
}