[PATCH obexd v2 10/11] Convenience method to make deep copy of a_header

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 gwobex/obex-xfer.c |   14 ++++++++++++++
 gwobex/obex-xfer.h |    2 ++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/gwobex/obex-xfer.c b/gwobex/obex-xfer.c
index fc85fbf..0ce476f 100644
--- a/gwobex/obex-xfer.c
+++ b/gwobex/obex-xfer.c
@@ -475,6 +475,20 @@ struct a_header *make_a_header(uint8_t hi, obex_headerdata_t hv,
     return ah;
 }
 
+struct a_header *a_header_copy(struct a_header *ah) {
+    struct a_header *res;
+    if (ah == NULL)
+        return NULL;
+    res = g_memdup(ah, sizeof(struct a_header));
+    switch (res->hi & OBEX_HDR_TYPE_MASK) {
+        case OBEX_HDR_TYPE_BYTES:
+        case OBEX_HDR_TYPE_UNICODE:
+            res->hv.bs = g_memdup(ah->hv.bs, ah->hv_size);
+            break;
+    }
+    return res;
+}
+
 void a_header_free(struct a_header *ah) {
     switch (ah->hi & OBEX_HDR_TYPE_MASK) {
         case OBEX_HDR_TYPE_BYTES:
diff --git a/gwobex/obex-xfer.h b/gwobex/obex-xfer.h
index 7c59827..844d726 100644
--- a/gwobex/obex-xfer.h
+++ b/gwobex/obex-xfer.h
@@ -96,6 +96,8 @@ void a_header_free(struct a_header *ah);
 struct a_header *make_a_header(uint8_t hi, obex_headerdata_t hv,
                                              unsigned int hlen);
 
+struct a_header *a_header_copy(struct a_header *ah);
+
 struct gw_obex_xfer *gw_obex_xfer_new(struct gw_obex *ctx, gboolean async, int stream_fd);
 
 void _gw_obex_xfer_free(struct gw_obex_xfer *xfer);
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux