Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions include/msgpack/unpack_define.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
#define MSGPACK_UNPACK_DEFINE_HPP

#include "msgpack/sysdep.hpp"
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdio.h>

#ifndef MSGPACK_EMBED_STACK_SIZE
#define MSGPACK_EMBED_STACK_SIZE 32
Expand Down Expand Up @@ -77,4 +73,3 @@ typedef enum {


#endif /* msgpack/unpack_define.hpp */

1 change: 0 additions & 1 deletion include/msgpack/v1/adaptor/ext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "msgpack/adaptor/check_container_size.hpp"
#include <cstring>
#include <string>
#include <cassert>

namespace msgpack {

Expand Down
1 change: 0 additions & 1 deletion include/msgpack/v1/adaptor/ext_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "msgpack/adaptor/adaptor_base.hpp"
#include <cstring>
#include <string>
#include <cassert>

namespace msgpack {

Expand Down
4 changes: 4 additions & 0 deletions include/msgpack/v1/fbuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <cstdio>
#include <stdexcept>

#include <boost/assert.hpp>

namespace msgpack {

/// @cond
Expand All @@ -28,6 +30,8 @@ class fbuffer {
public:
void write(const char* buf, unsigned int len)
{
BOOST_ASSERT(buf || len == 0);
if (!buf) return;
if (1 != fwrite(buf, len, 1, m_file)) {
throw std::runtime_error("fwrite() failed");
}
Expand Down
14 changes: 8 additions & 6 deletions include/msgpack/v1/sbuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

#include <stdexcept>
#include <cstring>
#include <cassert>

#include <boost/assert.hpp>

namespace msgpack {

Expand Down Expand Up @@ -69,14 +70,15 @@ class sbuffer {

void write(const char* buf, size_t len)
{
assert(buf || len == 0);
BOOST_ASSERT(buf || len == 0);

if (!buf) return;

if(m_alloc - m_size < len) {
expand_buffer(len);
}
if(buf) {
std::memcpy(m_data + m_size, buf, len);
m_size += len;
}
std::memcpy(m_data + m_size, buf, len);
m_size += len;
}

char* data()
Expand Down
4 changes: 3 additions & 1 deletion include/msgpack/v1/unpack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@

#include <memory>


#if !defined(MSGPACK_USE_CPP03)
#include <atomic>
#endif

#include <boost/assert.hpp>

#if defined(_MSC_VER)
// avoiding confliction std::max, std::min, and macro in windows.h
Expand Down Expand Up @@ -458,7 +460,7 @@ inline void context::check_ext_size<4>(std::size_t size) {

inline int context::execute(const char* data, std::size_t len, std::size_t& off)
{
assert(len >= off);
BOOST_ASSERT(len >= off);

m_start = data;
m_current = data + off;
Expand Down
6 changes: 6 additions & 0 deletions include/msgpack/v1/vrefbuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <stdexcept>
#include <algorithm>

#include <boost/assert.hpp>

#if defined(_MSC_VER)
// avoiding confliction std::max, std::min, and macro in windows.h
#ifndef NOMINMAX
Expand Down Expand Up @@ -107,6 +109,10 @@ class vrefbuffer {
public:
void write(const char* buf, size_t len)
{
BOOST_ASSERT(buf || len == 0);

if (!buf) return;

if(len < m_ref_size) {
append_copy(buf, len);
} else {
Expand Down
5 changes: 5 additions & 0 deletions include/msgpack/v1/zbuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <stdexcept>
#include <zlib.h>

#include <boost/assert.hpp>

namespace msgpack {

/// @cond
Expand Down Expand Up @@ -46,6 +48,9 @@ class zbuffer {
public:
void write(const char* buf, size_t len)
{
BOOST_ASSERT(buf || len == 0);
if (!buf) return;

m_stream.next_in = reinterpret_cast<Bytef*>(const_cast<char*>(buf));
m_stream.avail_in = static_cast<uInt>(len);

Expand Down
6 changes: 4 additions & 2 deletions include/msgpack/v2/create_object_visitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#ifndef MSGPACK_V2_CREATE_OBJECT_VISITOR_HPP
#define MSGPACK_V2_CREATE_OBJECT_VISITOR_HPP

#include <cassert>
#include <boost/assert.hpp>

#include "msgpack/unpack_decl.hpp"
#include "msgpack/unpack_exception.hpp"
Expand Down Expand Up @@ -108,7 +108,7 @@ class create_object_visitor : public msgpack::v2::null_visitor {
return true;
}
bool visit_str(const char* v, uint32_t size) {
assert(v || size == 0);
BOOST_ASSERT(v || size == 0);
if (size > m_limit.str()) throw msgpack::str_size_overflow("str size overflow");
msgpack::object* obj = m_stack.back();
obj->type = msgpack::type::STR;
Expand All @@ -132,6 +132,7 @@ class create_object_visitor : public msgpack::v2::null_visitor {
return true;
}
bool visit_bin(const char* v, uint32_t size) {
BOOST_ASSERT(v || size == 0);
if (size > m_limit.bin()) throw msgpack::bin_size_overflow("bin size overflow");
msgpack::object* obj = m_stack.back();
obj->type = msgpack::type::BIN;
Expand All @@ -155,6 +156,7 @@ class create_object_visitor : public msgpack::v2::null_visitor {
return true;
}
bool visit_ext(const char* v, uint32_t size) {
BOOST_ASSERT(v || size == 0);
if (size > m_limit.ext()) throw msgpack::ext_size_overflow("ext size overflow");
msgpack::object* obj = m_stack.back();
obj->type = msgpack::type::EXT;
Expand Down
8 changes: 5 additions & 3 deletions include/msgpack/v2/parse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include <cstddef>

#include <boost/assert.hpp>

#include "msgpack/unpack_define.hpp"
#include "msgpack/parse_return.hpp"
#include "msgpack/unpack_exception.hpp"
Expand Down Expand Up @@ -165,10 +167,10 @@ class context {
case MSGPACK_CT_MAP_KEY:
return visitor_holder.visitor().start_map_key() ? PARSE_CONTINUE : PARSE_STOP_VISITOR;
case MSGPACK_CT_MAP_VALUE:
assert(0);
BOOST_ASSERT(0);
return PARSE_STOP_VISITOR;
}
assert(0);
BOOST_ASSERT(0);
return PARSE_STOP_VISITOR;
}
parse_return consume(VisitorHolder& visitor_holder) {
Expand Down Expand Up @@ -234,7 +236,7 @@ inline void check_ext_size<4>(std::size_t size) {
template <typename VisitorHolder>
inline parse_return context<VisitorHolder>::execute(const char* data, std::size_t len, std::size_t& off)
{
assert(len >= off);
BOOST_ASSERT(len >= off);

m_start = data;
m_current = data + off;
Expand Down
8 changes: 5 additions & 3 deletions include/msgpack/v3/parse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include <cstddef>

#include <boost/assert.hpp>

#include "msgpack/parse_return.hpp"

namespace msgpack {
Expand Down Expand Up @@ -159,10 +161,10 @@ class context {
case MSGPACK_CT_MAP_KEY:
return visitor_holder.visitor().start_map_key() ? PARSE_CONTINUE : PARSE_STOP_VISITOR;
case MSGPACK_CT_MAP_VALUE:
assert(0);
BOOST_ASSERT(0);
return PARSE_STOP_VISITOR;
}
assert(0);
BOOST_ASSERT(0);
return PARSE_STOP_VISITOR;
}
parse_return consume(VisitorHolder& visitor_holder, char const*& current) {
Expand Down Expand Up @@ -243,7 +245,7 @@ inline void check_ext_size<4>(std::size_t size) {
template <typename VisitorHolder>
inline parse_return context<VisitorHolder>::execute(const char* data, std::size_t len, std::size_t& off)
{
assert(len >= off);
BOOST_ASSERT(len >= off);

m_start = data;
m_current = data + off;
Expand Down