Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes writer max annotation option doesn't work. #260

Merged
merged 2 commits into from
Dec 1, 2021
Merged
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
8 changes: 6 additions & 2 deletions ionc/ion_writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ iERR _ion_writer_open_helper(ION_WRITER **p_pwriter, ION_STREAM *stream, ION_WRI
writer_type = ion_type_text_writer;
}

IONCHECK(ion_temp_buffer_init(pwriter, &pwriter->temp_buffer, ION_WRITER_TEMP_BUFFER_DEFAULT));
// calculate annotations size by writer option's max_annotation_count field
SIZE temp_buffer_size = p_options->max_annotation_count * sizeof(ION_SYMBOL) + ION_WRITER_TEMP_BUFFER_DEFAULT;
IONCHECK(ion_temp_buffer_init(pwriter, &pwriter->temp_buffer, temp_buffer_size));

// allocate a temp pool we can reset from time to time
IONCHECK( _ion_writer_allocate_temp_pool( pwriter ));
Expand Down Expand Up @@ -1094,7 +1096,9 @@ iERR _ion_writer_add_annotation_helper(ION_WRITER *pwriter, ION_STRING *annotati
ASSERT(annotation->length >= 0);

if (!pwriter->annotations) {
IONCHECK(_ion_writer_set_max_annotation_count_helper(pwriter, DEFAULT_ANNOTATION_LIMIT));
int final_max_annotation_count = (pwriter->options.max_annotation_count > DEFAULT_ANNOTATION_LIMIT)
? pwriter->options.max_annotation_count : DEFAULT_ANNOTATION_LIMIT;
IONCHECK(_ion_writer_set_max_annotation_count_helper(pwriter, final_max_annotation_count));
}
else if (pwriter->annotation_curr >= pwriter->annotation_count) FAILWITH(IERR_TOO_MANY_ANNOTATIONS);

Expand Down