[
https://issues.apache.org/jira/browse/DISPATCH-1390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16915972#comment-16915972
]
ASF GitHub Bot commented on DISPATCH-1390:
------------------------------------------
kgiusti commented on pull request #543: DISPATCH-1390 - qd_buffer_list_clone is
copying too much data
URL: https://github.com/apache/qpid-dispatch/pull/543#discussion_r317707890
##########
File path: src/buffer.c
##########
@@ -65,19 +65,17 @@ unsigned int qd_buffer_list_clone(qd_buffer_list_t *dst,
const qd_buffer_list_t
qd_buffer_t *buf = DEQ_HEAD(*src);
while (buf) {
size_t to_copy = qd_buffer_size(buf);
- unsigned char *src = qd_buffer_base(buf);
+ unsigned char *src_base = qd_buffer_base(buf);
len += to_copy;
while (to_copy) {
- qd_buffer_t *newbuf = qd_buffer();
- size_t count = qd_buffer_capacity(newbuf);
- // default buffer capacity may have changed,
- // so don't assume it will fit:
- if (count > to_copy) count = to_copy;
- memcpy(qd_buffer_cursor(newbuf), src, count);
- qd_buffer_insert(newbuf, count);
+ qd_buffer_t *const restrict newbuf = qd_buffer();
+ const size_t new_capacity = qd_buffer_capacity(newbuf);
+ const size_t copy_size = to_copy < new_capacity ? to_copy :
new_capacity;
Review comment:
How does this differ from the original code? Won't it copy the same amount?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> qd_buffer_list_clone is copying too much data
> ---------------------------------------------
>
> Key: DISPATCH-1390
> URL: https://issues.apache.org/jira/browse/DISPATCH-1390
> Project: Qpid Dispatch
> Issue Type: Bug
> Reporter: Francesco Nigro
> Priority: Major
>
> qd_buffer_list_clone is ignoring the size of the src buffer and always copy
> the entire capacity
> of it into the destination buffer.
--
This message was sent by Atlassian Jira
(v8.3.2#803003)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]