Skip to content

Commit 88a72b8

Browse files
committed
Make c99, c23 compatible
1 parent 7071ff8 commit 88a72b8

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

ext/rbs_extension/location.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#define RBS_LOC_REQUIRED_P(loc, i) ((loc)->children->required_p & (1 << (i)))
44
#define RBS_LOC_OPTIONAL_P(loc, i) (!RBS_LOC_REQUIRED_P((loc), (i)))
5-
#define RBS_LOC_CHILDREN_SIZE(cap) (sizeof(rbs_loc_children) + sizeof(rbs_loc_entry) * (cap))
5+
#define RBS_LOC_CHILDREN_SIZE(cap) (sizeof(rbs_loc_children) + sizeof(rbs_loc_entry) * ((cap) - 1))
66

77
VALUE RBS_Location;
88

ext/rbs_extension/location.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,19 @@ typedef struct {
1616

1717
typedef unsigned int rbs_loc_entry_bitmap;
1818

19+
// The flexible array always allocates, but it's okay.
20+
// This struct is not allocated when the `rbs_loc` doesn't have children.
1921
typedef struct {
2022
unsigned short len;
2123
unsigned short cap;
2224
rbs_loc_entry_bitmap required_p;
23-
rbs_loc_entry entries[0];
25+
rbs_loc_entry entries[1];
2426
} rbs_loc_children;
2527

2628
typedef struct {
2729
VALUE buffer;
2830
range rg;
29-
rbs_loc_children *children;
31+
rbs_loc_children *children; // NULL when no children is allocated
3032
} rbs_loc;
3133

3234
/**

0 commit comments

Comments
 (0)