Commit a5defd43 authored by Kenton Varda's avatar Kenton Varda

Remove more obsolete STL from message.c++.

parent b601cf0f
......@@ -25,9 +25,6 @@
#include "arena.h"
#include "orphan.h"
#include <stdlib.h>
#include <exception>
#include <string>
#include <vector>
#include <errno.h>
namespace capnp {
......@@ -58,7 +55,7 @@ bool MessageReader::isCanonical() {
static_assert(sizeof(_::ReaderArena) <= sizeof(arenaSpace),
"arenaSpace is too small to hold a ReaderArena. Please increase it. This will break "
"ABI compatibility.");
new(arena()) _::ReaderArena(this);
kj::ctor(*arena(), this);
allocatedArena = true;
}
......@@ -89,7 +86,7 @@ AnyPointer::Reader MessageReader::getRootInternal() {
static_assert(sizeof(_::ReaderArena) <= sizeof(arenaSpace),
"arenaSpace is too small to hold a ReaderArena. Please increase it. This will break "
"ABI compatibility.");
new(arena()) _::ReaderArena(this);
kj::ctor(*arena(), this);
allocatedArena = true;
}
......@@ -199,10 +196,6 @@ kj::ArrayPtr<const word> SegmentArrayMessageReader::getSegment(uint id) {
// -------------------------------------------------------------------
struct MallocMessageBuilder::MoreSegments {
std::vector<void*> segments;
};
MallocMessageBuilder::MallocMessageBuilder(
uint firstSegmentWords, AllocationStrategy allocationStrategy)
: nextSize(firstSegmentWords), allocationStrategy(allocationStrategy),
......@@ -233,10 +226,8 @@ MallocMessageBuilder::~MallocMessageBuilder() noexcept(false) {
}
}
KJ_IF_MAYBE(s, moreSegments) {
for (void* ptr: s->get()->segments) {
free(ptr);
}
for (void* ptr: moreSegments) {
free(ptr);
}
}
}
......@@ -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.
if (allocationStrategy == AllocationStrategy::GROW_HEURISTICALLY) nextSize = size;
} else {
MoreSegments* segments;
KJ_IF_MAYBE(s, moreSegments) {
segments = *s;
} else {
auto newSegments = kj::heap<MoreSegments>();
segments = newSegments;
moreSegments = mv(newSegments);
}
segments->segments.push_back(result);
moreSegments.add(result);
if (allocationStrategy == AllocationStrategy::GROW_HEURISTICALLY) {
// set nextSize = min(nextSize+size, MAX_SEGMENT_WORDS)
// while protecting against possible overflow of (nextSize+size)
......
......@@ -23,6 +23,7 @@
#include <kj/memory.h>
#include <kj/mutex.h>
#include <kj/debug.h>
#include <kj/vector.h>
#include "common.h"
#include "layout.h"
#include "any.h"
......@@ -387,9 +388,7 @@ private:
bool returnedFirstSegment;
void* firstSegment;
struct MoreSegments;
kj::Maybe<kj::Own<MoreSegments>> moreSegments;
kj::Vector<void*> moreSegments;
};
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