Commit be33564f authored by Kenton Varda's avatar Kenton Varda

Merge branch 'master' of github.com:kentonv/capnproto

parents 4361912b f86ebf44
...@@ -1609,6 +1609,7 @@ struct WireHelpers { ...@@ -1609,6 +1609,7 @@ struct WireHelpers {
return { segment, ptr }; return { segment, ptr };
} else { } else {
// List of structs. // List of structs.
KJ_DASSERT(value.structDataSize % BITS_PER_WORD == 0 * BITS);
word* ptr = allocate(ref, segment, capTable, totalSize + POINTER_SIZE_IN_WORDS, word* ptr = allocate(ref, segment, capTable, totalSize + POINTER_SIZE_IN_WORDS,
WirePointer::LIST, orphanArena); WirePointer::LIST, orphanArena);
ref->listRef.setInlineComposite(totalSize); ref->listRef.setInlineComposite(totalSize);
......
...@@ -643,7 +643,8 @@ class ListBuilder: public kj::DisallowConstCopy { ...@@ -643,7 +643,8 @@ class ListBuilder: public kj::DisallowConstCopy {
public: public:
inline explicit ListBuilder(ElementSize elementSize) inline explicit ListBuilder(ElementSize elementSize)
: segment(nullptr), capTable(nullptr), ptr(nullptr), elementCount(0 * ELEMENTS), : segment(nullptr), capTable(nullptr), ptr(nullptr), elementCount(0 * ELEMENTS),
step(0 * BITS / ELEMENTS), elementSize(elementSize) {} step(0 * BITS / ELEMENTS), elementSize(elementSize), structDataSize(0 * BITS),
structPointerCount(0 * POINTERS) {}
MSVC_DEFAULT_ASSIGNMENT_WORKAROUND(, ListBuilder) MSVC_DEFAULT_ASSIGNMENT_WORKAROUND(, ListBuilder)
......
...@@ -103,6 +103,22 @@ public: ...@@ -103,6 +103,22 @@ public:
} }
} }
inline void operator=(decltype(nullptr)) {
builder = nullptr;
}
inline void clear() {
while (builder.size() > 0) {
builder.removeLast();
}
}
inline void truncate(size_t size) {
while (builder.size() > size) {
builder.removeLast();
}
}
private: private:
ArrayBuilder<T> builder; ArrayBuilder<T> builder;
......
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