Don't use VLA's in unit tests and API examples (#3002)
MSVC doesn't support C99 VLA (variable-length array). Use fixed size arrays in API examples and use JERRY_VLA macro in unit tests to make these tests buildable on Windows too. JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
This commit is contained in:
committed by
Robert Fancsik
parent
051febfed7
commit
9c7511221f
@@ -86,7 +86,7 @@ resolve_differently_handled_module (const jerry_value_t name,
|
||||
jerry_value_t *result)
|
||||
{
|
||||
jerry_size_t name_size = jerry_get_utf8_string_size (name);
|
||||
jerry_char_t name_string[name_size];
|
||||
JERRY_VLA (jerry_char_t, name_string, name_size);
|
||||
jerry_string_to_utf8_char_buffer (name, name_string, name_size);
|
||||
|
||||
if (!strncmp ((char *) name_string, "differently-handled-module", name_size))
|
||||
@@ -113,7 +113,7 @@ cache_check (const jerry_value_t name,
|
||||
jerry_value_t *result)
|
||||
{
|
||||
jerry_size_t name_size = jerry_get_utf8_string_size (name);
|
||||
jerry_char_t name_string[name_size];
|
||||
JERRY_VLA (jerry_char_t, name_string, name_size);
|
||||
jerry_string_to_utf8_char_buffer (name, name_string, name_size);
|
||||
|
||||
if (!strncmp ((char *) name_string, "cache-check", name_size))
|
||||
|
||||
@@ -836,7 +836,7 @@ test_utf8_string (void)
|
||||
jerry_value_t str = jerry_create_string ((jerry_char_t *) "\x73\x74\x72\x3a \xed\xa0\x81\xed\xb0\x80");
|
||||
char expect_utf8_buf[] = "\x73\x74\x72\x3a \xf0\x90\x90\x80";
|
||||
size_t buf_len = sizeof (expect_utf8_buf) - 1;
|
||||
char buf[buf_len+1];
|
||||
JERRY_VLA (char, buf, buf_len + 1);
|
||||
|
||||
jerryx_arg_t mapping[] =
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@ static jerry_value_t
|
||||
get_canonical_name (const jerry_value_t name)
|
||||
{
|
||||
jerry_size_t name_size = jerry_get_string_size (name);
|
||||
jerry_char_t name_string[name_size + 1];
|
||||
JERRY_VLA (jerry_char_t, name_string, name_size + 1);
|
||||
jerry_string_to_char_buffer (name, name_string, name_size);
|
||||
name_string[name_size] = 0;
|
||||
|
||||
@@ -48,7 +48,7 @@ static bool
|
||||
resolve (const jerry_value_t canonical_name, jerry_value_t *result)
|
||||
{
|
||||
jerry_size_t name_size = jerry_get_string_size (canonical_name);
|
||||
jerry_char_t name_string[name_size + 1];
|
||||
JERRY_VLA (jerry_char_t, name_string, name_size + 1);
|
||||
jerry_string_to_char_buffer (canonical_name, name_string, name_size);
|
||||
name_string[name_size] = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user