Skip to content

Commit ae828bd

Browse files
committed
Moving our safeint3 to be in its own namespace to not conflict with any Visual Studio version.
1 parent 84bdc2b commit ae828bd

File tree

13 files changed

+36
-45
lines changed

13 files changed

+36
-45
lines changed

Release/include/cpprest/containerstream.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ namespace Concurrency { namespace streams {
131131
// seek beyond the current write_end.
132132
_ASSERTE(m_current_position <= m_data.size());
133133

134-
SafeSize readhead(m_current_position);
135-
SafeSize writeend(m_data.size());
134+
msl::safeint3::SafeInt<size_t> readhead(m_current_position);
135+
msl::safeint3::SafeInt<size_t> writeend(m_data.size());
136136
return (size_t)(writeend - readhead);
137137
}
138138

@@ -434,8 +434,8 @@ namespace Concurrency { namespace streams {
434434
if (!can_satisfy(count))
435435
return 0;
436436

437-
SafeSize request_size(count);
438-
SafeSize read_size = request_size.Min(in_avail());
437+
msl::safeint3::SafeInt<size_t> request_size(count);
438+
msl::safeint3::SafeInt<size_t> read_size = request_size.Min(in_avail());
439439

440440
size_t newPos = m_current_position + read_size;
441441

Release/include/cpprest/details/SafeInt3.hpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -536,13 +536,11 @@ SAFEINT_DISABLE_SHIFT_ASSERT - Set this option if you don't want to assert
536536
#define __int64 long long
537537
#endif
538538

539-
#if defined VISUAL_STUDIO_SAFEINT_COMPAT
540539
namespace msl
541540
{
542541

543-
namespace utilities
542+
namespace safeint3
544543
{
545-
#endif
546544

547545
// catch these to handle errors
548546
// Currently implemented code values:
@@ -555,10 +553,8 @@ enum SafeIntError
555553
SafeIntDivideByZero
556554
};
557555

558-
#if defined VISUAL_STUDIO_SAFEINT_COMPAT
559-
} // utilities
556+
} // safeint3
560557
} // msl
561-
#endif
562558

563559

564560
/*
@@ -637,13 +633,11 @@ enum SafeIntError
637633
#define SAFEINT_NOTHROW throw()
638634
#endif
639635

640-
#if defined VISUAL_STUDIO_SAFEINT_COMPAT
641636
namespace msl
642637
{
643638

644-
namespace utilities
639+
namespace safeint3
645640
{
646-
#endif
647641

648642
// If you would like to use your own custom assert
649643
// Define SAFEINT_ASSERT
@@ -7050,8 +7044,6 @@ SafeInt< T, E > operator |( U lhs, SafeInt< T, E > rhs ) SAFEINT_NOTHROW
70507044
#endif
70517045
#endif //SAFEINT_HPP
70527046

7053-
#if defined VISUAL_STUDIO_SAFEINT_COMPAT
70547047
} // utilities
7055-
} // msl
7056-
#endif
7048+
} // safeint3
70577049

Release/include/cpprest/details/basic_types.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#endif
4040

4141
#include "cpprest/details/SafeInt3.hpp"
42-
typedef SafeInt<size_t> SafeSize;
4342

4443
namespace utility
4544
{

Release/include/cpprest/details/fileio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ namespace details
7474
char *m_buffer;
7575

7676
size_t m_bufoff; // File position that the start of the buffer represents.
77-
SafeSize m_bufsize; // Buffer allocated size, as actually allocated.
77+
msl::safeint3::SafeInt<size_t> m_bufsize; // Buffer allocated size, as actually allocated.
7878
size_t m_buffill; // Amount of file data actually in the buffer
7979

8080
std::ios_base::openmode m_mode;

Release/include/cpprest/filestream.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ namespace details {
189189
if ( m_info->m_buffer == nullptr || m_info->m_buffill == 0 ) return 0;
190190
if ( m_info->m_bufoff > m_info->m_rdpos || (m_info->m_bufoff+m_info->m_buffill) < m_info->m_rdpos ) return 0;
191191

192-
SafeInt<size_t> rdpos(m_info->m_rdpos);
193-
SafeInt<size_t> buffill(m_info->m_buffill);
194-
SafeInt<size_t> bufpos = rdpos - m_info->m_bufoff;
192+
msl::safeint3::SafeInt<size_t> rdpos(m_info->m_rdpos);
193+
msl::safeint3::SafeInt<size_t> buffill(m_info->m_buffill);
194+
msl::safeint3::SafeInt<size_t> bufpos = rdpos - m_info->m_bufoff;
195195

196196
return buffill - bufpos;
197197
}

Release/include/cpprest/json.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -876,9 +876,9 @@ namespace json
876876
/// <returns>A reference to the value kept in the field.</returns>
877877
json::value& operator[](size_type index)
878878
{
879-
SafeInt<size_type> nMinSize(index);
879+
msl::safeint3::SafeInt<size_type> nMinSize(index);
880880
nMinSize += 1;
881-
SafeInt<size_type> nlastSize(m_elements.size());
881+
msl::safeint3::SafeInt<size_type> nlastSize(m_elements.size());
882882
if (nlastSize < nMinSize)
883883
m_elements.resize(nMinSize);
884884

Release/include/cpprest/producerconsumerstream.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ namespace Concurrency { namespace streams {
390390
// Allocate a new block if necessary
391391
if ( m_blocks.empty() || m_blocks.back()->wr_chars_left() < count )
392392
{
393-
SafeSize alloc = m_alloc_size.Max(count);
393+
msl::safeint3::SafeInt<size_t> alloc = m_alloc_size.Max(count);
394394
m_blocks.push_back(std::make_shared<_block>((size_t)alloc));
395395
}
396396

@@ -468,7 +468,7 @@ namespace Concurrency { namespace streams {
468468
// Read up to count characters from the block
469469
size_t read(_Out_writes_ (count) _CharType * dest, _In_ size_t count, bool advance = true)
470470
{
471-
SafeSize avail(rd_chars_left());
471+
msl::safeint3::SafeInt<size_t> avail(rd_chars_left());
472472
auto countRead = static_cast<size_t>(avail.Min(count));
473473

474474
_CharType * beg = rbegin();
@@ -492,7 +492,7 @@ namespace Concurrency { namespace streams {
492492
// Write count characters into the block
493493
size_t write(const _CharType * src, size_t count)
494494
{
495-
SafeSize avail(wr_chars_left());
495+
msl::safeint3::SafeInt<size_t> avail(wr_chars_left());
496496
auto countWritten = static_cast<size_t>(avail.Min(count));
497497

498498
const _CharType * srcEnd = src + countWritten;
@@ -647,7 +647,7 @@ namespace Concurrency { namespace streams {
647647
std::ios_base::openmode m_mode;
648648

649649
// Default block size
650-
SafeSize m_alloc_size;
650+
msl::safeint3::SafeInt<size_t> m_alloc_size;
651651

652652
// Block used for alloc/commit
653653
std::shared_ptr<_block> m_allocBlock;

Release/include/cpprest/rawptrstream.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ namespace Concurrency { namespace streams {
133133
// seek beyond the current size.
134134
_ASSERTE(m_current_position <= m_size);
135135

136-
SafeSize readhead(m_current_position);
137-
SafeSize writeend(m_size);
136+
msl::safeint3::SafeInt<size_t> readhead(m_current_position);
137+
msl::safeint3::SafeInt<size_t> writeend(m_size);
138138
return (size_t)(writeend - readhead);
139139
}
140140

@@ -178,7 +178,7 @@ namespace Concurrency { namespace streams {
178178

179179
virtual pplx::task<size_t> _putn(const _CharType *ptr, size_t count)
180180
{
181-
SafeSize newSize = SafeSize(count) + m_current_position;
181+
msl::safeint3::SafeInt<size_t> newSize = msl::safeint3::SafeInt<size_t>(count) + m_current_position;
182182
if ( newSize > m_size )
183183
return pplx::task_from_exception<size_t>(std::make_exception_ptr(std::runtime_error("Writing past the end of the buffer")));
184184
return pplx::task_from_result<size_t>(this->write(ptr, count));
@@ -193,8 +193,8 @@ namespace Concurrency { namespace streams {
193193
{
194194
if (!this->can_write()) return nullptr;
195195

196-
SafeSize readhead(m_current_position);
197-
SafeSize writeend(m_size);
196+
msl::safeint3::SafeInt<size_t> readhead(m_current_position);
197+
msl::safeint3::SafeInt<size_t> writeend(m_size);
198198
size_t space_left = (size_t)(writeend - readhead);
199199

200200
if (space_left < count) return nullptr;
@@ -476,8 +476,8 @@ namespace Concurrency { namespace streams {
476476
if (!can_satisfy(count))
477477
return 0;
478478

479-
SafeSize request_size(count);
480-
SafeSize read_size = request_size.Min(in_avail());
479+
msl::safeint3::SafeInt<size_t> request_size(count);
480+
msl::safeint3::SafeInt<size_t> read_size = request_size.Min(in_avail());
481481

482482
size_t newPos = m_current_position + read_size;
483483

@@ -506,7 +506,7 @@ namespace Concurrency { namespace streams {
506506
{
507507
if (!this->can_write() || (count == 0)) return 0;
508508

509-
SafeSize newSize = SafeSize(count) + m_current_position;
509+
msl::safeint3::SafeInt<size_t> newSize = msl::safeint3::SafeInt<size_t>(count) +m_current_position;
510510

511511
if ( newSize > m_size )
512512
throw std::runtime_error("Writing past the end of the buffer");

Release/src/http/client/http_client_winhttp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ class winhttp_client : public _http_client_communicator
783783
static void _multiple_segment_write_data(_In_ winhttp_request_context * p_request_context)
784784
{
785785
auto rbuf = p_request_context->_get_readbuffer();
786-
SafeInt<utility::size64_t> safeCount = p_request_context->m_remaining_to_write;
786+
msl::safeint3::SafeInt<utility::size64_t> safeCount = p_request_context->m_remaining_to_write;
787787
safeCount = safeCount.Min(p_request_context->m_http_client->client_config().chunksize());
788788

789789
uint8_t* block = nullptr;

Release/src/http/client/http_client_winrt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ class IRequestStream
216216
auto buffer = context->_get_readbuffer();
217217

218218
// Do not read more than the specified read_length
219-
SafeSize safe_count = static_cast<size_t>(cb);
219+
msl::safeint3::SafeInt<size_t> safe_count = static_cast<size_t>(cb);
220220
size_t size_to_read = safe_count.Min(m_read_length);
221221

222222
const size_t count = buffer.getn((uint8_t *)pv, size_to_read).get();

0 commit comments

Comments
 (0)