[ 
https://issues.apache.org/jira/browse/PROTON-1823?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16429036#comment-16429036
 ] 

ASF subversion and git services commented on PROTON-1823:
---------------------------------------------------------

Commit dc724c140d23158ac3059292b27962cc276acdc8 in qpid-proton's branch 
refs/heads/master from [~aconway]
[ https://git-wip-us.apache.org/repos/asf?p=qpid-proton.git;h=dc724c1 ]

PROTON-1823: [c] pn_message_send() simplified message sending for C

Encapsulates the awkward allocate-encode-expand dance required by 
pn_message_encode()
Supports the following 2 scenarios:

1. Simple: don't care about allocations, just send `pn_message_t *msg` and 
forget it:

    pn_message_send(msg, sender, NULL)

2. Efficient: re-use a buffer, buffer is allocated and expanded as required:

    pn_rwbytes_t buffer={0};     // Zero initialize, libary will do the 
allocation
    ...
    pn_message_send(msg, sender, &buffer); // Expand as needed
    pn_message_send(msg2, sender2, &buffer); // etc.
    ...
    free(buffer->start);        // Application must do final free of buffer

Note 2. assumes use of malloc/realloc/free, apps that need custom allocation can
use the original pn_message_encode() API or we could add a version that takes a 
pointer
to a function equivalent to realloc()

Updated examples to use this API.


> [c] make it easier to send a message
> ------------------------------------
>
>                 Key: PROTON-1823
>                 URL: https://issues.apache.org/jira/browse/PROTON-1823
>             Project: Qpid Proton
>          Issue Type: Improvement
>          Components: proton-c
>    Affects Versions: proton-c-0.22.0
>            Reporter: Alan Conway
>            Assignee: Alan Conway
>            Priority: Minor
>             Fix For: proton-c-0.23.0
>
>
> Encapsulates the awkward allocate-encode-expand dance required by 
> pn_message_encode()
> Supports the following 2 scenarios:
> 1. Simple: don't care about allocations, just send `pn_message_t *msg` and 
> forget it:
>     pn_message_send(msg, sender, NULL)
> 2. Efficient: re-use a buffer, buffer is allocated and expanded as required:
>     pn_rwbytes_t buffer=\{0};     // Zero initialize, libary will do the 
> allocation
>     ...
>     pn_message_send(msg, sender, &buffer); // Expand as needed
>     pn_message_send(msg2, sender2, &buffer); // etc.
>     ...
>     free(buffer->start);        // Application must do final free of buffer



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org
For additional commands, e-mail: dev-h...@qpid.apache.org

Reply via email to