pass ubus_msg_buf to callback of internal object
[project/ubus.git] / ubusd.c
diff --git a/ubusd.c b/ubusd.c
index bcc8603..8903105 100644 (file)
--- a/ubusd.c
+++ b/ubusd.c
 
 #include "ubusd.h"
 
-static struct ubus_msg_buf *ubus_msg_unshare(struct ubus_msg_buf *ub)
-{
-       ub = realloc(ub, sizeof(*ub) + ub->len);
-       if (!ub)
-               return NULL;
-
-       ub->refcount = 1;
-       memcpy(ub + 1, ub->data, ub->len);
-       ub->data = (void *) (ub + 1);
-       return ub;
-}
-
 static struct ubus_msg_buf *ubus_msg_ref(struct ubus_msg_buf *ub)
 {
        if (ub->refcount == ~0)
-               return ubus_msg_unshare(ub);
+               return ubus_msg_new(ub->data, ub->len, false);
 
        ub->refcount++;
        return ub;