Skip to content

Commit 3b87472

Browse files
committed
max_cap_ is a member of fields_base
1 parent a5deebe commit 3b87472

8 files changed

Lines changed: 22 additions & 37 deletions

File tree

include/boost/http_proto/detail/header.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,6 @@ struct header
123123
char const* cbuf = nullptr;
124124
char* buf = nullptr;
125125
std::size_t cap = 0;
126-
std::size_t max_cap =
127-
std::numeric_limits<
128-
std::size_t>::max();
129126

130127
offset_type size = 0;
131128
offset_type count = 0;

include/boost/http_proto/fields.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ class fields final
214214
swap(fields& other) noexcept
215215
{
216216
h_.swap(other.h_);
217+
std::swap(max_cap_, other.max_cap_);
217218
}
218219

219220
/** Swap two instances

include/boost/http_proto/fields_base.hpp

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ class fields_base
3838
: public virtual fields_view_base
3939
{
4040
detail::header h_;
41-
bool static_storage = false;
41+
bool static_storage_ = false;
42+
std::size_t max_cap_ =
43+
std::numeric_limits<
44+
std::size_t>::max();
4245

4346
using entry =
4447
detail::header::entry;
@@ -77,7 +80,6 @@ class fields_base
7780
friend class static_response;
7881
friend class serializer;
7982
friend class message_base;
80-
friend struct detail::header;
8183
friend struct detail::prefix_op;
8284

8385
BOOST_HTTP_PROTO_DECL
@@ -142,7 +144,7 @@ class fields_base
142144
std::size_t
143145
max_capacity_in_bytes() noexcept
144146
{
145-
return h_.max_cap;
147+
return max_cap_;
146148
}
147149

148150
/** Returns the total number of bytes allocated by the container
@@ -588,20 +590,6 @@ class fields_base
588590
void raw_erase_n(field, std::size_t) noexcept;
589591
};
590592

591-
//------------------------------------------------
592-
593-
#ifndef BOOST_HTTP_PROTO_DOCS
594-
namespace detail {
595-
inline
596-
header&
597-
header::
598-
get(fields_base& f) noexcept
599-
{
600-
return f.h_;
601-
}
602-
} // detail
603-
#endif
604-
605593
} // http_proto
606594
} // boost
607595

include/boost/http_proto/request.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ class request
194194
swap(request& other) noexcept
195195
{
196196
h_.swap(other.h_);
197+
std::swap(max_cap_, other.max_cap_);
197198
}
198199

199200
/** Swap two instances

include/boost/http_proto/response.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ class response
213213
swap(response& other) noexcept
214214
{
215215
h_.swap(other.h_);
216+
std::swap(max_cap_, other.max_cap_);
216217
}
217218

218219
/** Swap two instances

src/detail/header.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ swap(header& h) noexcept
137137
std::swap(cbuf, h.cbuf);
138138
std::swap(buf, h.buf);
139139
std::swap(cap, h.cap);
140-
std::swap(max_cap, h.max_cap);
141140
std::swap(size, h.size);
142141
std::swap(count, h.count);
143142
std::swap(prefix, h.prefix);
@@ -339,12 +338,10 @@ assign_to(
339338
auto const buf_ = dest.buf;
340339
auto const cbuf_ = dest.cbuf;
341340
auto const cap_ = dest.cap;
342-
auto const max_cap_ = dest.max_cap;
343341
dest = *this;
344342
dest.buf = buf_;
345343
dest.cbuf = cbuf_;
346344
dest.cap = cap_;
347-
dest.max_cap = max_cap_;
348345
}
349346

350347
//------------------------------------------------

src/fields_base.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ op_t::
171171
reserve(
172172
std::size_t n)
173173
{
174-
if(n > self_.max_capacity_in_bytes())
174+
if(n > self_.max_cap_)
175175
{
176176
// max capacity exceeded
177177
detail::throw_length_error();
@@ -270,7 +270,7 @@ prefix_op_t(
270270
{
271271
// static storage will always throw which is
272272
// intended since they cannot reallocate.
273-
if(self.h_.max_cap < new_size)
273+
if(self.max_cap_ < new_size)
274274
detail::throw_length_error();
275275

276276
auto bytes_needed =
@@ -347,14 +347,14 @@ fields_base(
347347
std::size_t storage_size) noexcept
348348
: fields_view_base(&h_)
349349
, h_(k)
350-
, static_storage(true)
350+
, static_storage_(true)
351351
{
352352
h_.buf = storage;
353353
h_.cap = align_down(
354354
storage,
355355
storage_size,
356356
alignof(detail::header::entry));
357-
h_.max_cap = h_.cap;
357+
max_cap_ = h_.cap;
358358
}
359359

360360
fields_base::
@@ -367,7 +367,7 @@ fields_base(
367367
if(storage_size != 0)
368368
{
369369
reserve_bytes(storage_size);
370-
h_.max_cap = h_.cap;
370+
max_cap_ = h_.cap;
371371
}
372372
}
373373

@@ -383,7 +383,7 @@ fields_base(
383383
detail::throw_length_error();
384384

385385
reserve_bytes(storage_size);
386-
h_.max_cap = max_storage_size;
386+
max_cap_ = max_storage_size;
387387
}
388388

389389
// copy s and parse it
@@ -427,15 +427,15 @@ fields_base(
427427
core::string_view s)
428428
: fields_view_base(&h_)
429429
, h_(detail::empty{k})
430-
, static_storage(true)
430+
, static_storage_(true)
431431
{
432432
h_.cbuf = storage;
433433
h_.buf = storage;
434434
h_.cap = align_down(
435435
storage,
436436
storage_size,
437437
alignof(detail::header::entry));
438-
h_.max_cap = h_.cap;
438+
max_cap_ = h_.cap;
439439

440440
auto n = detail::header::count_crlf(s);
441441
if(h_.kind == detail::kind::fields)
@@ -492,14 +492,14 @@ fields_base(
492492
std::size_t storage_size)
493493
: fields_view_base(&h_)
494494
, h_(h.kind)
495-
, static_storage(true)
495+
, static_storage_(true)
496496
{
497497
h_.buf = storage;
498498
h_.cap = align_down(
499499
storage,
500500
storage_size,
501501
alignof(detail::header::entry));
502-
h_.max_cap = h_.cap;
502+
max_cap_ = h_.cap;
503503

504504
if(h.is_default())
505505
return;
@@ -522,7 +522,7 @@ fields_base(
522522
fields_base::
523523
~fields_base()
524524
{
525-
if(h_.buf && !static_storage)
525+
if(h_.buf && !static_storage_)
526526
delete[] h_.buf;
527527
}
528528

@@ -578,7 +578,7 @@ shrink_to_fit() noexcept
578578
h_.cap)
579579
return;
580580

581-
if(static_storage)
581+
if(static_storage_)
582582
return;
583583

584584
fields_base tmp(h_);
@@ -941,7 +941,7 @@ copy_impl(
941941
return;
942942
}
943943

944-
if(static_storage)
944+
if(static_storage_)
945945
{
946946
if(h.is_default())
947947
{

src/rfc/detail/rules.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <boost/url/grammar/parse.hpp>
2323
#include <boost/url/grammar/tuple_rule.hpp>
2424

25-
#include "rules.hpp"
25+
#include "src/rfc/detail/rules.hpp"
2626

2727
namespace boost {
2828
namespace http_proto {

0 commit comments

Comments
 (0)