summaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
Diffstat (limited to 'document')
-rw-r--r--document/src/vespa/document/datatype/structureddatatype.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/document/src/vespa/document/datatype/structureddatatype.cpp b/document/src/vespa/document/datatype/structureddatatype.cpp
index 1b98d912819..59584ff3b01 100644
--- a/document/src/vespa/document/datatype/structureddatatype.cpp
+++ b/document/src/vespa/document/datatype/structureddatatype.cpp
@@ -48,11 +48,18 @@ int32_t StructuredDataType::createId(vespalib::stringref name)
// ASCII characters. Probably screwed up otherwise, but generated ids
// should only be used in testing anyways. In production this will be
// set from the document manager config.
- char *bufOnStack = static_cast<char *>(alloca(name.size() + 2));
- memcpy(bufOnStack, name.data(), name.size());
- bufOnStack[name.size()] = '.';
- bufOnStack[name.size() + 1] = '0';
- return crappyJavaStringHash(vespalib::stringref(bufOnStack, name.size() + 2));
+ constexpr size_t BUFFER_SIZE = 1024;
+ if ((name.size() + 2) < BUFFER_SIZE) {
+ char buf[BUFFER_SIZE];
+ memcpy(buf, name.data(), name.size());
+ buf[name.size()] = '.';
+ buf[name.size() + 1] = '0';
+ return crappyJavaStringHash(vespalib::stringref(buf, name.size() + 2));
+ } else {
+ vespalib::asciistream ost;
+ ost << name << ".0"; // Hardcode version 0 (version is not supported).
+ return crappyJavaStringHash(ost.str());
+ }
}
void