Hi,
> I have a variable in my structure like:
> pb_bytes_array_t **IPAddr;
>
> Where the length of the intended array would be 4.
If you know the size, put it in .options or .proto
(max_size:4 for the length of the bytes contents, max_count:4 for the
number of bytes entries). Then you will get easier to fill variable.
But if you need variable-length variable-count, do this:
// N is number of entries, M is length of each entry.
msg->IPAddr = malloc(sizeof(void*) * N);
msg->IPAddr[0] = malloc(PB_BYTES_ARRAY_T_ALLOCSIZE(M))
msg->IPAddr[0]->size = M;
memcpy(&msg->IPAddr[0]->bytes, &mydata, M);
.. same for IPAddr[1] etc. ...
> Otherwise the bytes array only has one element:
This technique is known as a variable length array member.
It (ab)uses the C property that you can index past an array, and relies
on the user to allocate necessary space.
--
Petteri