add blob_attr_equal() for comparing attributes
[project/libubox.git] / blob.h
diff --git a/blob.h b/blob.h
index 341de27..80ad7d0 100644 (file)
--- a/blob.h
+++ b/blob.h
@@ -175,27 +175,27 @@ blob_set_raw_len(struct blob_attr *attr, unsigned int len)
 }
 
 static inline uint8_t
-blob_get_int8(const struct blob_attr *attr)
+blob_get_u8(const struct blob_attr *attr)
 {
        return *((uint8_t *) attr->data);
 }
 
 static inline uint16_t
-blob_get_int16(const struct blob_attr *attr)
+blob_get_u16(const struct blob_attr *attr)
 {
        uint16_t *tmp = (uint16_t*)attr->data;
        return be16_to_cpu(*tmp);
 }
 
 static inline uint32_t
-blob_get_int32(const struct blob_attr *attr)
+blob_get_u32(const struct blob_attr *attr)
 {
        uint32_t *tmp = (uint32_t*)attr->data;
        return be32_to_cpu(*tmp);
 }
 
 static inline uint64_t
-blob_get_int64(const struct blob_attr *attr)
+blob_get_u64(const struct blob_attr *attr)
 {
        uint64_t *tmp = (uint64_t*)attr->data;
        return be64_to_cpu(*tmp);
@@ -213,7 +213,17 @@ blob_next(const struct blob_attr *attr)
        return (struct blob_attr *) ((char *) attr + blob_pad_len(attr));
 }
 
+static inline bool
+blob_attr_equal(const struct blob_attr *a1, const struct blob_attr *a2)
+{
+       if (blob_pad_len(a1) != blob_pad_len(a2))
+               return false;
+
+       return !memcmp(a1, a2, blob_pad_len(a1));
+}
+
 extern int blob_buf_init(struct blob_buf *buf, int id);
+extern void blob_buf_free(struct blob_buf *buf);
 extern struct blob_attr *blob_new(struct blob_buf *buf, int id, int payload);
 extern void *blob_nest_start(struct blob_buf *buf, int id);
 extern void blob_nest_end(struct blob_buf *buf, void *cookie);