blobmsg: make arrays structually the same as tables - simplifies library user code

This commit is contained in:
Felix Fietkau 2011-01-29 18:00:40 +01:00
parent 34b9f56464
commit 5129bc9401
3 changed files with 31 additions and 53 deletions

View file

@ -35,7 +35,7 @@ enum blobmsg_type {
};
struct blobmsg_hdr {
uint8_t namelen;
uint16_t namelen;
uint8_t name[];
} __packed;
@ -58,7 +58,7 @@ static inline void *blobmsg_name(struct blob_attr *attr)
static inline void *blobmsg_data(struct blob_attr *attr)
{
struct blobmsg_hdr *hdr = blob_data(attr);
return &hdr->name[blobmsg_hdrlen(hdr->namelen) - 1];
return (char *) hdr + blobmsg_hdrlen(hdr->namelen);
}
static inline int blobmsg_data_len(struct blob_attr *attr)