Fixed "linked" strings incorrectly marked as "owned" (fixes #1318)

This commit is contained in:
Benoit Blanchon
2020-07-24 22:25:56 +02:00
parent 6dc36125c2
commit 4df29fbac1
9 changed files with 75 additions and 74 deletions

View File

@@ -4,12 +4,13 @@
#pragma once
#include <stdint.h> // int8_t, int16_t
#include <ArduinoJson/Polyfills/gsl/not_null.hpp>
#include <ArduinoJson/Polyfills/type_traits.hpp>
#include <ArduinoJson/Strings/StoragePolicy.hpp>
#include <ArduinoJson/Variant/VariantContent.hpp>
#include <stdint.h> // int8_t, int16_t
namespace ARDUINOJSON_NAMESPACE {
typedef conditional<sizeof(void*) <= 2, int8_t, int16_t>::type VariantSlotDiff;
@@ -69,14 +70,16 @@ class VariantSlot {
_next = VariantSlotDiff(slot - this);
}
void setOwnedKey(not_null<const char*> k) {
void setKey(const char* k, storage_policies::store_by_copy) {
ARDUINOJSON_ASSERT(k != NULL);
_flags |= KEY_IS_OWNED;
_key = k.get();
_key = k;
}
void setLinkedKey(not_null<const char*> k) {
void setKey(const char* k, storage_policies::store_by_address) {
ARDUINOJSON_ASSERT(k != NULL);
_flags &= VALUE_MASK;
_key = k.get();
_key = k;
}
const char* key() const {