-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
None
Sometimes, C structs contain a trailing variable-length array:
```
struct foo {
int length;
char name[]; // size is 'length'
};
```
If we give this to jextract we obtain the attached declaration. There are few issues with it:
* the static allocate methods just allocate a "bare" struct with no space for the array. Instead the allocate methods could accept the length of the trailing array, and allocate enough space for the struct + array
* there is no getter/setter for the variable-length array elements. These can be added easily - if the supplied segment is too small, an out of bound error will occur.
These changes could make working with VLAs a bit easier.
```
struct foo {
int length;
char name[]; // size is 'length'
};
```
If we give this to jextract we obtain the attached declaration. There are few issues with it:
* the static allocate methods just allocate a "bare" struct with no space for the array. Instead the allocate methods could accept the length of the trailing array, and allocate enough space for the struct + array
* there is no getter/setter for the variable-length array elements. These can be added easily - if the supplied segment is too small, an out of bound error will occur.
These changes could make working with VLAs a bit easier.