[code] Avoid dynamic allocation and useless string copy by keeping the

importation status flag in the areaBuffer
This commit is contained in:
Émilie Feral
2018-09-11 16:21:35 +02:00
parent db3cd16128
commit 79740e72b0
9 changed files with 25 additions and 45 deletions

View File

@@ -25,14 +25,4 @@ const char * Script::readContent() const {
return (const char *)d.buffer+k_importationStatusSize;
}
Ion::Storage::Record::ErrorStatus Script::writeContent(const char * data, size_t size) {
// TODO: could we avoid this useless allocation?
char * buffer = new char[size+k_importationStatusSize];
strlcpy(buffer+1, data, size);
buffer[0] = importationStatus() ? 1 : 0;
ErrorStatus e = setValue({.buffer= buffer, .size = size+k_importationStatusSize});
delete[] buffer;
return e;
}
}