kkdwivedi
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @05:53PM (#22871965)
Right, totally depends on what you're doing. My example is not a good fit for intrusive use cases.
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @04:34PM (#22871107)
Another option is a struct with a FAM at the end.
typedef struct {
size_t len;
uint8_t data[];
} ByteBuf;
Then, allocation becomes ByteBuf *b = malloc(sizeof(*b) + sizeof(uint8_t) * array_size);
b->len = array_size;
and data is no longer a pointer.