Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit e1109df

Browse files
committed
ehh, actually in all list structs capacity goes before len. added explicit tests for lists where len != capacity
1 parent 89b6497 commit e1109df

File tree

14 files changed

+28
-14
lines changed

14 files changed

+28
-14
lines changed

bytes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
typedef struct LIB_RUBY_PARSER_ByteList
1111
{
1212
char *ptr;
13-
size_t len;
1413
size_t capacity;
14+
size_t len;
1515
} LIB_RUBY_PARSER_ByteList;
1616
/*
1717
ByteList destructor.

comment.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ typedef struct LIB_RUBY_PARSER_Comment
3636
typedef struct LIB_RUBY_PARSER_CommentList
3737
{
3838
LIB_RUBY_PARSER_Comment *ptr;
39-
size_t len;
4039
size_t capacity;
40+
size_t len;
4141
} LIB_RUBY_PARSER_CommentList;
4242

4343
/*

diagnostic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ void LIB_RUBY_PARSER_drop_diagnostic(LIB_RUBY_PARSER_Diagnostic *diagnostic);
5858
typedef struct LIB_RUBY_PARSER_DiagnosticList
5959
{
6060
LIB_RUBY_PARSER_Diagnostic *ptr;
61-
size_t len;
6261
size_t capacity;
62+
size_t len;
6363
} LIB_RUBY_PARSER_DiagnosticList;
6464
/*
6565
DiagnosticList destructor.

magic_comment.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ typedef struct LIB_RUBY_PARSER_MagicComment
3131
typedef struct LIB_RUBY_PARSER_MagicCommentList
3232
{
3333
LIB_RUBY_PARSER_MagicComment *ptr;
34-
size_t len;
3534
size_t capacity;
35+
size_t len;
3636
} LIB_RUBY_PARSER_MagicCommentList;
3737

3838
/*

ruby-parser-c/src/bytes.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ blob_type!(BytesBlob, Bytes);
77
#[cfg(feature = "tests")]
88
#[no_mangle]
99
pub extern "C" fn lib_ruby_parser__test__make_byte_list(i1: u8, i2: u8, i3: u8) -> ByteListBlob {
10-
ByteListBlob::from(vec![i1, i2, i3])
10+
let mut v = vec![i1, i2, i3];
11+
v.reserve(10);
12+
ByteListBlob::from(v)
1113
}
1214

1315
#[no_mangle]

ruby-parser-c/src/comment.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ pub extern "C" fn lib_ruby_parser__test__make_comment(location: Loc, kind: Comme
3434
#[cfg(feature = "tests")]
3535
#[no_mangle]
3636
pub extern "C" fn lib_ruby_parser__test__make_comment_list(comment: Comment) -> CommentListBlob {
37-
CommentListBlob::from(vec![comment])
37+
let mut v = vec![comment];
38+
v.reserve(10);
39+
CommentListBlob::from(v)
3840
}
3941

4042
#[no_mangle]

ruby-parser-c/src/diagnostic.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ pub extern "C" fn LIB_RUBY_PARSER_drop_diagnostic(diagnostic: *mut Diagnostic) {
3232
pub extern "C" fn lib_ruby_parser__test__make_diagnostic_list(
3333
diagnostic: DiagnosticBlob,
3434
) -> DiagnosticListBlob {
35-
DiagnosticListBlob::from(vec![Diagnostic::from(diagnostic)])
35+
let mut v = vec![Diagnostic::from(diagnostic)];
36+
v.reserve(10);
37+
DiagnosticListBlob::from(v)
3638
}
3739

3840
#[no_mangle]

ruby-parser-c/src/magic_comment.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ pub extern "C" fn lib_ruby_parser__test__make_magic_comment(
5252
pub extern "C" fn lib_ruby_parser__test__make_magic_comment_list(
5353
magic_comment: MagicComment,
5454
) -> MagicCommentListBlob {
55-
MagicCommentListBlob::from(vec![magic_comment])
55+
let mut v = vec![magic_comment];
56+
v.reserve(10);
57+
MagicCommentListBlob::from(v)
5658
}
5759

5860
#[no_mangle]

ruby-parser-c/src/source_line.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ pub extern "C" fn lib_ruby_parser__test__make_source_line(
2222
pub extern "C" fn lib_ruby_parser__test__make_source_line_list(
2323
source_line: SourceLine,
2424
) -> SourceLineListBlob {
25-
SourceLineListBlob::from(vec![source_line])
25+
let mut v = vec![source_line];
26+
v.reserve(10);
27+
SourceLineListBlob::from(v)
2628
}
2729

2830
#[no_mangle]

ruby-parser-c/src/string.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ pub extern "C" fn LIB_RUBY_PARSER_new_string_from_cstr(ptr: *const i8) -> String
1818
#[cfg(feature = "tests")]
1919
#[no_mangle]
2020
pub extern "C" fn lib_ruby_parser__test__make_string_foo() -> StringBlob {
21-
StringBlob::from(String::from("foo"))
21+
let mut s = String::from("foo");
22+
s.reserve(20);
23+
StringBlob::from(s)
2224
}
2325

2426
#[no_mangle]

0 commit comments

Comments
 (0)