Commit a5defd43 authored by Kenton Varda's avatar Kenton Varda

Remove more obsolete STL from message.c++.

parent b601cf0f
...@@ -25,9 +25,6 @@ ...@@ -25,9 +25,6 @@
#include "arena.h" #include "arena.h"
#include "orphan.h" #include "orphan.h"
#include <stdlib.h> #include <stdlib.h>
#include <exception>
#include <string>
#include <vector>
#include <errno.h> #include <errno.h>
namespace capnp { namespace capnp {
...@@ -58,7 +55,7 @@ bool MessageReader::isCanonical() { ...@@ -58,7 +55,7 @@ bool MessageReader::isCanonical() {
static_assert(sizeof(_::ReaderArena) <= sizeof(arenaSpace), static_assert(sizeof(_::ReaderArena) <= sizeof(arenaSpace),
"arenaSpace is too small to hold a ReaderArena. Please increase it. This will break " "arenaSpace is too small to hold a ReaderArena. Please increase it. This will break "
"ABI compatibility."); "ABI compatibility.");
new(arena()) _::ReaderArena(this); kj::ctor(*arena(), this);
allocatedArena = true; allocatedArena = true;
} }
...@@ -89,7 +86,7 @@ AnyPointer::Reader MessageReader::getRootInternal() { ...@@ -89,7 +86,7 @@ AnyPointer::Reader MessageReader::getRootInternal() {
static_assert(sizeof(_::ReaderArena) <= sizeof(arenaSpace), static_assert(sizeof(_::ReaderArena) <= sizeof(arenaSpace),
"arenaSpace is too small to hold a ReaderArena. Please increase it. This will break " "arenaSpace is too small to hold a ReaderArena. Please increase it. This will break "
"ABI compatibility."); "ABI compatibility.");
new(arena()) _::ReaderArena(this); kj::ctor(*arena(), this);
allocatedArena = true; allocatedArena = true;
} }
...@@ -199,10 +196,6 @@ kj::ArrayPtr<const word> SegmentArrayMessageReader::getSegment(uint id) { ...@@ -199,10 +196,6 @@ kj::ArrayPtr<const word> SegmentArrayMessageReader::getSegment(uint id) {
// ------------------------------------------------------------------- // -------------------------------------------------------------------
struct MallocMessageBuilder::MoreSegments {
std::vector<void*> segments;
};
MallocMessageBuilder::MallocMessageBuilder( MallocMessageBuilder::MallocMessageBuilder(
uint firstSegmentWords, AllocationStrategy allocationStrategy) uint firstSegmentWords, AllocationStrategy allocationStrategy)
: nextSize(firstSegmentWords), allocationStrategy(allocationStrategy), : nextSize(firstSegmentWords), allocationStrategy(allocationStrategy),
...@@ -233,10 +226,8 @@ MallocMessageBuilder::~MallocMessageBuilder() noexcept(false) { ...@@ -233,10 +226,8 @@ MallocMessageBuilder::~MallocMessageBuilder() noexcept(false) {
} }
} }
KJ_IF_MAYBE(s, moreSegments) { for (void* ptr: moreSegments) {
for (void* ptr: s->get()->segments) { free(ptr);
free(ptr);
}
} }
} }
} }
...@@ -273,15 +264,7 @@ kj::ArrayPtr<word> MallocMessageBuilder::allocateSegment(uint minimumSize) { ...@@ -273,15 +264,7 @@ kj::ArrayPtr<word> MallocMessageBuilder::allocateSegment(uint minimumSize) {
// After the first segment, we want nextSize to equal the total size allocated so far. // After the first segment, we want nextSize to equal the total size allocated so far.
if (allocationStrategy == AllocationStrategy::GROW_HEURISTICALLY) nextSize = size; if (allocationStrategy == AllocationStrategy::GROW_HEURISTICALLY) nextSize = size;
} else { } else {
MoreSegments* segments; moreSegments.add(result);
KJ_IF_MAYBE(s, moreSegments) {
segments = *s;
} else {
auto newSegments = kj::heap<MoreSegments>();
segments = newSegments;
moreSegments = mv(newSegments);
}
segments->segments.push_back(result);
if (allocationStrategy == AllocationStrategy::GROW_HEURISTICALLY) { if (allocationStrategy == AllocationStrategy::GROW_HEURISTICALLY) {
// set nextSize = min(nextSize+size, MAX_SEGMENT_WORDS) // set nextSize = min(nextSize+size, MAX_SEGMENT_WORDS)
// while protecting against possible overflow of (nextSize+size) // while protecting against possible overflow of (nextSize+size)
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <kj/memory.h> #include <kj/memory.h>
#include <kj/mutex.h> #include <kj/mutex.h>
#include <kj/debug.h> #include <kj/debug.h>
#include <kj/vector.h>
#include "common.h" #include "common.h"
#include "layout.h" #include "layout.h"
#include "any.h" #include "any.h"
...@@ -387,9 +388,7 @@ private: ...@@ -387,9 +388,7 @@ private:
bool returnedFirstSegment; bool returnedFirstSegment;
void* firstSegment; void* firstSegment;
kj::Vector<void*> moreSegments;
struct MoreSegments;
kj::Maybe<kj::Own<MoreSegments>> moreSegments;
}; };
class FlatMessageBuilder: public MessageBuilder { class FlatMessageBuilder: public MessageBuilder {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment