You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/07/23 02:47:30 UTC

[03/11] incubator-mynewt-core git commit: os - Add an mbuf function: os_mbuf_prepend_pullup

os - Add an mbuf function: os_mbuf_prepend_pullup

/**
 * Prepends a chunk of empty data to the specified mbuf chain and
 * ensures the chunk is contiguous.  If either operation fails, the
 * specified mbuf chain is freed and NULL is returned.
 *
 * @param om                    The mbuf chain to prepend to.
 * @param len                   The number of bytes to prepend and
 *                                  pullup.
 *
 * @return                      The modified mbuf on success;
 *                              NULL on failure (and the mbuf chain is
 *                                  freed).
 */
struct os_mbuf *
os_mbuf_prepend_pullup(struct os_mbuf *om, uint16_t len)


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/5c4b292e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/5c4b292e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/5c4b292e

Branch: refs/heads/develop
Commit: 5c4b292edb2523a30585740171b025048912f0d9
Parents: 010602f
Author: Christopher Collins <cc...@apache.org>
Authored: Thu Jul 21 12:26:55 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Fri Jul 22 18:34:01 2016 -0700

----------------------------------------------------------------------
 libs/os/include/os/os_mbuf.h |  1 +
 libs/os/src/os_mbuf.c        | 27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5c4b292e/libs/os/include/os/os_mbuf.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/os_mbuf.h b/libs/os/include/os/os_mbuf.h
index 785cafe..93e5ba4 100644
--- a/libs/os/include/os/os_mbuf.h
+++ b/libs/os/include/os/os_mbuf.h
@@ -284,6 +284,7 @@ int os_mbuf_cmpm(const struct os_mbuf *om1, uint16_t offset1,
                  uint16_t len);
 
 struct os_mbuf *os_mbuf_prepend(struct os_mbuf *om, int len);
+struct os_mbuf *os_mbuf_prepend_pullup(struct os_mbuf *om, uint16_t len);
 int os_mbuf_copyinto(struct os_mbuf *om, int off, const void *src, int len);
 void os_mbuf_concat(struct os_mbuf *first, struct os_mbuf *second);
 void *os_mbuf_extend(struct os_mbuf *om, uint16_t len);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5c4b292e/libs/os/src/os_mbuf.c
----------------------------------------------------------------------
diff --git a/libs/os/src/os_mbuf.c b/libs/os/src/os_mbuf.c
index 2703caf..8306d16 100644
--- a/libs/os/src/os_mbuf.c
+++ b/libs/os/src/os_mbuf.c
@@ -967,6 +967,33 @@ os_mbuf_prepend(struct os_mbuf *om, int len)
 }
 
 /**
+ * Prepends a chunk of empty data to the specified mbuf chain and ensures the
+ * chunk is contiguous.  If either operation fails, the specified mbuf chain is
+ * freed and NULL is returned.
+ *
+ * @param om                    The mbuf chain to prepend to.
+ * @param len                   The number of bytes to prepend and pullup.
+ *
+ * @return                      The modified mbuf on success;
+ *                              NULL on failure (and the mbuf chain is freed).
+ */
+struct os_mbuf *
+os_mbuf_prepend_pullup(struct os_mbuf *om, uint16_t len)
+{
+    om = os_mbuf_prepend(om, len);
+    if (om == NULL) {
+        return NULL;
+    }
+
+    om = os_mbuf_pullup(om, len);
+    if (om == NULL) {
+        return NULL;
+    }
+
+    return om;
+}
+
+/**
  * Copies the contents of a flat buffer into an mbuf chain, starting at the
  * specified destination offset.  If the mbuf is too small for the source data,
  * it is extended as necessary.  If the destination mbuf contains a packet