Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,12 @@ yaml_string_join(
YAML_DECLARE(int)
yaml_stack_extend(void **start, void **top, void **end)
{
void *new_start = yaml_realloc(*start, ((char *)*end - (char *)*start)*2);
void *new_start;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sticking to C89? What are our supported operating systems if we're deciding to stick to that?


if ((char *)*end - (char *)*start >= INT_MAX / 2)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason not to calculate

(char *)*end - (char *)*start

Once and use it here and below? I know it shouldn't change very much, but I feel like it'll be cleaner, especially if we give it a very clear name.

return 0;

new_start = yaml_realloc(*start, ((char *)*end - (char *)*start)*2);

if (!new_start) return 0;

Expand Down