mirror of
https://github.com/neovim/neovim.git
synced 2025-10-16 06:46:07 +00:00
refactor: use flexible arrays instead of the length-of-one trick (#22072)
The "length-of-one" trick, where the last element of a struct is an array of size 1, but extra size is allocated when calling malloc where it uses more than 1 element in the array, cause problems with some compilers. Some compilers set _FORTIFY_SOURCE=2 by default which incorrectly considers it as an overflow. More information: https://github.com/neovim/neovim/issues/223#issuecomment-1413828554 Using flexible array members allows us to to properly convey to the compiler that its size may be larger than 1. This also enables us to remove lengthy workarounds that are unreliable, as they depend on CMAKE_BUILD_TYPE which isn't defined for multi-config generators. Closes: https://github.com/neovim/neovim/issues/223
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
typedef struct signgroup_S {
|
||||
int sg_next_sign_id; ///< next sign id for this group
|
||||
uint16_t sg_refcount; ///< number of signs in this group
|
||||
char sg_name[1]; ///< sign group name, actually longer
|
||||
char sg_name[]; ///< sign group name
|
||||
} signgroup_T;
|
||||
|
||||
// Macros to get the sign group structure from the group name
|
||||
|
Reference in New Issue
Block a user