@@ -3115,8 +3115,8 @@ static rbs_ast_comment_t *parse_comment_lines(rbs_parser_t *parser, rbs_comment_
31153115 rbs_buffer_t rbs_buffer ;
31163116 rbs_buffer_init (ALLOCATOR (), & rbs_buffer );
31173117
3118- for (size_t i = 0 ; i < com -> line_count ; i ++ ) {
3119- rbs_token_t tok = com -> tokens [i ];
3118+ for (size_t i = 0 ; i < com -> line_tokens_count ; i ++ ) {
3119+ rbs_token_t tok = com -> line_tokens [i ];
31203120
31213121 const char * comment_start = parser -> rbs_lexer_t -> string .start + tok .range .start .byte_pos + hash_bytes ;
31223122 size_t comment_bytes = RBS_RANGE_BYTES (tok .range ) - hash_bytes ;
@@ -3160,23 +3160,23 @@ static rbs_comment_t *comment_get_comment(rbs_comment_t *com, int line) {
31603160}
31613161
31623162static void comment_insert_new_line (rbs_allocator_t * allocator , rbs_comment_t * com , rbs_token_t comment_token ) {
3163- if (com -> line_count == 0 ) {
3163+ if (com -> line_tokens_count == 0 ) {
31643164 com -> start = comment_token .range .start ;
31653165 }
31663166
3167- if (com -> line_count == com -> line_size ) {
3168- com -> line_size += 10 ;
3167+ if (com -> line_tokens_count == com -> line_tokens_capacity ) {
3168+ com -> line_tokens_capacity += 10 ;
31693169
3170- if (com -> tokens ) {
3171- rbs_token_t * p = com -> tokens ;
3172- com -> tokens = rbs_allocator_calloc (allocator , com -> line_size , rbs_token_t );
3173- memcpy (com -> tokens , p , sizeof (rbs_token_t ) * com -> line_count );
3170+ if (com -> line_tokens ) {
3171+ rbs_token_t * p = com -> line_tokens ;
3172+ com -> line_tokens = rbs_allocator_calloc (allocator , com -> line_tokens_capacity , rbs_token_t );
3173+ memcpy (com -> line_tokens , p , sizeof (rbs_token_t ) * com -> line_tokens_count );
31743174 } else {
3175- com -> tokens = rbs_allocator_calloc (allocator , com -> line_size , rbs_token_t );
3175+ com -> line_tokens = rbs_allocator_calloc (allocator , com -> line_tokens_capacity , rbs_token_t );
31763176 }
31773177 }
31783178
3179- com -> tokens [com -> line_count ++ ] = comment_token ;
3179+ com -> line_tokens [com -> line_tokens_count ++ ] = comment_token ;
31803180 com -> end = comment_token .range .end ;
31813181}
31823182
@@ -3187,9 +3187,9 @@ static rbs_comment_t *alloc_comment(rbs_allocator_t *allocator, rbs_token_t comm
31873187 .start = comment_token .range .start ,
31883188 .end = comment_token .range .end ,
31893189
3190- .line_size = 0 ,
3191- .line_count = 0 ,
3192- .tokens = NULL ,
3190+ .line_tokens_capacity = 0 ,
3191+ .line_tokens_count = 0 ,
3192+ .line_tokens = NULL ,
31933193
31943194 .next_comment = last_comment ,
31953195 };
0 commit comments