+ ret = realloc(s.buf, s.pos + 1);
+ if (!ret) {
+ free(s.buf);
+ return NULL;
+ }
+
+ ret[s.pos] = 0;
+
+ return ret;
+}
+
+char *blobmsg_format_json_value_with_cb(struct blob_attr *attr, blobmsg_json_format_t cb, void *priv, int indent)
+{
+ struct strbuf s = {0};
+ char *ret;
+
+ setup_strbuf(&s, attr, cb, priv, indent);
+ if (!s.buf)
+ return NULL;
+
+ blobmsg_format_element(&s, attr, true, false);
+
+ if (!s.len) {
+ free(s.buf);
+ return NULL;
+ }
+
+ ret = realloc(s.buf, s.pos + 1);
+ if (!ret) {
+ free(s.buf);
+ return NULL;
+ }