Move write_offset from struct netconn to struct api_msg

This moves the write_offset variable from struct netconn to struct api_msg

This optimizes the storage by only having the space claimed when it is
needed (during a netconn_write_partly() call) and not throughout the
lifetime of the netconn

This also reduces code space/execution by not having to separately manage
clearing/checking write_offset from the current_msg pointer

Lastly, we also save execution by using msg.w.offset as the output
rather than marshaling the result to msg.w.len. Previously, len was used
as input length of dataptr and output for the write operation.
netconn_write_partly() also has access to msg.w.offset, so we can use
that
This commit is contained in:
Joel Cunningham
2017-02-17 13:26:16 -06:00
parent deaa6e9406
commit 4c76fd500c
4 changed files with 22 additions and 32 deletions

View File

@@ -258,9 +258,6 @@ struct netconn {
/** flags holding more netconn-internal state, see NETCONN_FLAG_* defines */
u8_t flags;
#if LWIP_TCP
/** TCP: when data passed to netconn_write doesn't fit into the send buffer,
this temporarily stores how much is already sent. */
size_t write_offset;
/** TCP: when data passed to netconn_write doesn't fit into the send buffer,
this temporarily stores the message.
Also used during connect and close. */

View File

@@ -104,7 +104,10 @@ struct api_msg {
/** used for lwip_netconn_do_write */
struct {
const void *dataptr;
/** total length of dataptr */
size_t len;
/** offset into dataptr/output of bytes written */
size_t offset;
u8_t apiflags;
#if LWIP_SO_SNDTIMEO
u32_t time_started;