blobmsg: add a helper function to reset the name of a blobmsg attribute
[project/libubox.git] / blobmsg.h
index 082980a..7041aca 100644 (file)
--- a/blobmsg.h
+++ b/blobmsg.h
@@ -51,6 +51,12 @@ static inline int blobmsg_hdrlen(unsigned int namelen)
        return BLOBMSG_PADDING(sizeof(struct blobmsg_hdr) + namelen + 1);
 }
 
+static inline void blobmsg_clear_name(struct blob_attr *attr)
+{
+       struct blobmsg_hdr *hdr = (struct blobmsg_hdr *) blob_data(attr);
+       hdr->name[0] = 0;
+}
+
 static inline const char *blobmsg_name(const struct blob_attr *attr)
 {
        struct blobmsg_hdr *hdr = (struct blobmsg_hdr *) blob_data(attr);