summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-10-17 14:06:59 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-10-17 14:06:59 +0000
commit913d46f2fe1a41d3f7d9edda041df98279e1a002 (patch)
tree5450bdda138c5276e31837018e332694b98e3e45 /vespalib
parentb7123d3a07bc823961e452ad527d00e236012ebe (diff)
- Always check if enough space to write.
- Split large initSortData method. - make buffer resizing explicit and readable. - Make a better initial estimate for buffer size.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/util/sort.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/vespalib/src/vespa/vespalib/util/sort.h b/vespalib/src/vespa/vespalib/util/sort.h
index ce3f6772ef1..7d21cb4fe1a 100644
--- a/vespalib/src/vespa/vespalib/util/sort.h
+++ b/vespalib/src/vespa/vespalib/util/sort.h
@@ -271,8 +271,9 @@ public:
};
template<typename C>
-uint32_t serializeForSort(typename C::InputType v, void * dst) {
+int32_t serializeForSort(typename C::InputType v, void * dst, uint32_t available) {
typename C::UIntType nbo(vespalib::nbo::n2h(C::convert(v)));
+ if (available < sizeof(nbo)) return -1;
memcpy(dst, &nbo, sizeof(nbo));
return sizeof(nbo);
}