Skip to content

Commit

Permalink
Make c99, c23 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
soutaro committed Jun 7, 2024
1 parent 7071ff8 commit 88a72b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ext/rbs_extension/location.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

VALUE RBS_Location;

Expand Down
6 changes: 4 additions & 2 deletions ext/rbs_extension/location.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ typedef struct {

typedef unsigned int rbs_loc_entry_bitmap;

// The flexible array always allocates, but it's okay.
// This struct is not allocated when the `rbs_loc` doesn't have children.
typedef struct {
unsigned short len;
unsigned short cap;
rbs_loc_entry_bitmap required_p;
rbs_loc_entry entries[0];
rbs_loc_entry entries[1];
} rbs_loc_children;

typedef struct {
VALUE buffer;
range rg;
rbs_loc_children *children;
rbs_loc_children *children; // NULL when no children is allocated
} rbs_loc;

/**
Expand Down

0 comments on commit 88a72b8

Please sign in to comment.