Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/blob.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2013-02-10 23:43:33 +0400
committerFelix Fietkau <nbd@openwrt.org>2013-02-10 23:43:33 +0400
commitb786f852674769813061474366e936fe6e5bd22e (patch)
tree9e80e2a6812115c99e0319a82bf302b835e59ac1 /blob.c
parent9a3519536b7497a1423fbfa7e8981212a30f1793 (diff)
blob: add blob_buf_grow()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'blob.c')
-rw-r--r--blob.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/blob.c b/blob.c
index e74f07f..c18f5a9 100644
--- a/blob.c
+++ b/blob.c
@@ -50,6 +50,17 @@ attr_to_offset(struct blob_buf *buf, struct blob_attr *attr)
return (char *)attr - (char *) buf->buf;
}
+void
+blob_buf_grow(struct blob_buf *buf, int required)
+{
+ int offset_head = attr_to_offset(buf, buf->head);
+
+ if (!buf->grow || !buf->grow(buf, required))
+ return;
+
+ buf->head = offset_to_attr(buf, offset_head);
+}
+
static struct blob_attr *
blob_add(struct blob_buf *buf, struct blob_attr *pos, int id, int payload)
{
@@ -58,12 +69,7 @@ blob_add(struct blob_buf *buf, struct blob_attr *pos, int id, int payload)
struct blob_attr *attr;
if (required > 0) {
- int offset_head = attr_to_offset(buf, buf->head);
-
- if (!buf->grow || !buf->grow(buf, required))
- return NULL;
-
- buf->head = offset_to_attr(buf, offset_head);
+ blob_buf_grow(buf, required);
attr = offset_to_attr(buf, offset);
} else {
attr = pos;