diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-10-17 14:06:59 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-10-17 14:06:59 +0000 |
commit | 913d46f2fe1a41d3f7d9edda041df98279e1a002 (patch) | |
tree | 5450bdda138c5276e31837018e332694b98e3e45 /vespalib | |
parent | b7123d3a07bc823961e452ad527d00e236012ebe (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.h | 3 |
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); } |