Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 66e801f0 authored by Andre Eisenbach's avatar Andre Eisenbach
Browse files

Style guide: Use C99 style flexible arrays

Change-Id: I012d9f4195833e2c6c9a5c953e71b7a7b5847673
parent 74925d7d
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -87,13 +87,15 @@ void function(void);
Note that the function explicitly includes `void` in its parameter list to
indicate to the compiler that it takes no arguments.

### Zero-length arrays
Use zero-length arrays as the last member of a struct if the array needs to be
allocated in contiguous memory with its containing struct. For example:
### Contiguous memory structs
Use C99 flexible arrays as the last member of a struct if the array needs
to be allocated in contiguous memory with its containing struct.
A flexible array member is writen as array_name[] without a specific size.  
For example:
```
typedef struct {
  size_t length;
  uint8_t data[0];
  uint8_t data[];
} buffer_t;

// Allocate a buffer with 128 bytes available for my_buffer->data.
+2 −2

File changed.

Contains only whitespace changes.