From 47c13a98e082d7f1acce18b7de7cbf1e0cd3fe23 Mon Sep 17 00:00:00 2001 From: ameharoo <36627499+ameharoo@users.noreply.github.com> Date: Fri, 20 Sep 2024 15:37:31 +0400 Subject: [PATCH] Fix invalid alloc_size value. Add sizeof(protocol_hash_type) --- templates/cpp/Type.j2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/cpp/Type.j2 b/templates/cpp/Type.j2 index 3a5514f..8348d88 100644 --- a/templates/cpp/Type.j2 +++ b/templates/cpp/Type.j2 @@ -1,4 +1,4 @@ -{% from 'cpp/Hashtype.j2' import HashAssignment %} +{% from 'cpp/Hashtype.j2' import HashAssignment, HashType %} {% macro var_static_size_name(msg) -%}{{ msg | message_type | upper }}_STATIC_SIZE{% endmacro %} @@ -22,7 +22,7 @@ {% block before_definition %} {% block static_size_definition %} -constexpr std::size_t {{ var_static_size_name(msg) }} = +constexpr std::size_t {{ var_static_size_name(msg) }} = sizeof({{ HashType(data.protocol_hash_bytes_count) }}) + {%- if msg | message_novar_fields | length > 0 %} ({{ msg | message_novar_fields | map('field_type') | map('wrap', 'sizeof(', ')') | join(' + ') }}); {%- else %}