Skip to content

Commit e60dc6e

Browse files
committed
Improvements to step-test-Z80.
1 parent 86f96b3 commit e60dc6e

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

sources/step-test-Z80.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ static void print_cycle_mismatch(cJSON *test, zuint index, Cycle const *actual,
475475
if (actual->value != expected->value)
476476
printf(" %.2s/%.2s", actual_value, expected_value);
477477

478-
if (*(zuint32 *)actual->pins != *(zuint32 *)expected->pins)
478+
if (*(zuint32 const *)actual->pins != *(zuint32 const *)expected->pins)
479479
printf(" %.4s/%.4s", actual->pins, expected->pins);
480480
}
481481
}
@@ -679,7 +679,7 @@ int main(int argc, char **argv)
679679
goto bad_syntax;
680680
}
681681

682-
for (j = (zuint)i; j < argc; j++) if (*argv[j] == '\0')
682+
for (j = (zuint)i; j < (zuint)argc; j++) if (*argv[j] == '\0')
683683
{
684684
i = (int)j;
685685
invalid = "file path";
@@ -721,10 +721,10 @@ int main(int argc, char **argv)
721721

722722
for (; !read_from_stdin && i != argc; i++)
723723
{
724-
char const *parse_end = Z_NULL;
725-
char *json = Z_NULL;
726-
zusize json_size;
727-
cJSON *tests = Z_NULL;
724+
cJSON* tests = Z_NULL;
725+
char const* parse_end = Z_NULL;
726+
char* json = Z_NULL;
727+
zusize json_size = 0;
728728

729729
error = Z_NULL;
730730

@@ -736,9 +736,15 @@ int main(int argc, char **argv)
736736
printf("-: ");
737737

738738
do {
739-
if ((json = realloc(json, buffer_size += INPUT_BLOCK_SIZE)) == Z_NULL)
739+
char *buffer = realloc(json, buffer_size += INPUT_BLOCK_SIZE);
740+
741+
if (buffer == Z_NULL)
742+
{
743+
free(json);
740744
goto cannot_allocate_memory;
745+
}
741746

747+
json = buffer;
742748
json_size = fread(json + buffer_size - INPUT_BLOCK_SIZE, 1, INPUT_BLOCK_SIZE, stdin);
743749

744750
if (ferror(stdin))

0 commit comments

Comments
 (0)