diff options
author | Felix Fietkau <nbd@openwrt.org> | 2013-09-25 10:44:39 +0400 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2013-10-04 18:55:45 +0400 |
commit | be458596bd13f0a708d52efaa5c70bac2f8fe97d (patch) | |
tree | 0939fc3d8fbc0bf9decfd544807ee55005dbd146 /blob.c | |
parent | 460d94d6e8ef48cfad76057660cf0fa957cd0afa (diff) |
blob: add blob_put_raw() for copying one or more blob attributes into the buffer directly
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'blob.c')
-rw-r--r-- | blob.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -135,6 +135,20 @@ blob_new(struct blob_buf *buf, int id, int payload) } struct blob_attr * +blob_put_raw(struct blob_buf *buf, const void *ptr, int len) +{ + struct blob_attr *attr; + + if (len < sizeof(struct blob_attr) || !ptr) + return NULL; + + attr = blob_add(buf, blob_next(buf->head), 0, len - sizeof(struct blob_attr)); + blob_set_raw_len(buf->head, blob_pad_len(buf->head) + len); + memcpy(attr, ptr, len); + return attr; +} + +struct blob_attr * blob_put(struct blob_buf *buf, int id, const void *ptr, int len) { struct blob_attr *attr; |