diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-02-06 12:03:09 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-02-06 12:09:55 +0100 |
commit | f41e4b82a42e22f7cdc9a05d02125bdc63334e6a (patch) | |
tree | 923759c759ec906314ed2ec3a1644ffb8f6137d3 | |
parent | da8587b24e64e566a68e547ff42cf44e22714bda (diff) | |
download | systemd-f41e4b82a42e22f7cdc9a05d02125bdc63334e6a.tar.gz |
shared/json: avoid use of fake flex array
-rw-r--r-- | src/shared/json.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/shared/json.c b/src/shared/json.c index fd54835efa..c270048197 100644 --- a/src/shared/json.c +++ b/src/shared/json.c @@ -101,17 +101,12 @@ struct JsonVariant { /* If is_reference as indicated above is set, this is where the reference object is actually stored. */ JsonVariant *reference; - /* Strings are placed immediately after the structure. Note that when this is a JsonVariant embedded - * into an array we might encode strings up to INLINE_STRING_LENGTH characters directly inside the - * element, while longer strings are stored as references. When this object is not embedded into an - * array, but stand-alone we allocate the right size for the whole structure, i.e. the array might be - * much larger than INLINE_STRING_LENGTH. - * - * Note that because we want to allocate arrays of the JsonVariant structure we specify [0] here, - * rather than the prettier []. If we wouldn't, then this char array would have undefined size, and so - * would the union and then the struct this is included in. And of structures with undefined size we - * can't allocate arrays (at least not easily). */ - char string[0]; + /* Strings are placed immediately after the structure. Note that when this is a JsonVariant + * embedded into an array we might encode strings up to INLINE_STRING_LENGTH characters + * directly inside the element, while longer strings are stored as references. When this + * object is not embedded into an array, but stand-alone, we allocate the right size for the + * whole structure, i.e. the array might be much larger than INLINE_STRING_LENGTH. */ + DECLARE_FLEX_ARRAY(char, string); }; }; |