Jacek Caban : rpcrt4: Optimize buffer allocation in rpcrt4_ncacn_http_read.
Alexandre Julliard
julliard at winehq.org
Tue Aug 14 12:59:54 CDT 2012
Module: wine
Branch: master
Commit: 9eeedc27237655ee025509a9c6c944560b7fac55
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9eeedc27237655ee025509a9c6c944560b7fac55
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Aug 14 13:35:36 2012 +0200
rpcrt4: Optimize buffer allocation in rpcrt4_ncacn_http_read.
---
dlls/rpcrt4/rpc_transport.c | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/dlls/rpcrt4/rpc_transport.c b/dlls/rpcrt4/rpc_transport.c
index ef18c64..445f186 100644
--- a/dlls/rpcrt4/rpc_transport.c
+++ b/dlls/rpcrt4/rpc_transport.c
@@ -2440,31 +2440,32 @@ static int rpcrt4_ncacn_http_read(RpcConnection *Connection,
unsigned int bytes_left = count;
RPC_STATUS status = RPC_S_OK;
+ httpc->async_data->inet_buffers.lpvBuffer = HeapAlloc(GetProcessHeap(), 0, count);
+
while (bytes_left)
{
httpc->async_data->inet_buffers.dwBufferLength = bytes_left;
- httpc->async_data->inet_buffers.lpvBuffer = HeapAlloc(GetProcessHeap(), 0, bytes_left);
prepare_async_request(httpc->async_data);
ret = InternetReadFileExA(httpc->out_request, &httpc->async_data->inet_buffers, IRF_ASYNC, 0);
status = wait_async_request(httpc->async_data, ret, httpc->cancel_event);
if(status != RPC_S_OK) {
if(status == RPC_S_CALL_CANCELLED)
TRACE("call cancelled\n");
- HeapFree(GetProcessHeap(), 0, httpc->async_data->inet_buffers.lpvBuffer);
- httpc->async_data->inet_buffers.lpvBuffer = NULL;
break;
}
- memcpy(buf, httpc->async_data->inet_buffers.lpvBuffer,
- httpc->async_data->inet_buffers.dwBufferLength);
- HeapFree(GetProcessHeap(), 0, httpc->async_data->inet_buffers.lpvBuffer);
- httpc->async_data->inet_buffers.lpvBuffer = NULL;
if(!httpc->async_data->inet_buffers.dwBufferLength)
break;
+ memcpy(buf, httpc->async_data->inet_buffers.lpvBuffer,
+ httpc->async_data->inet_buffers.dwBufferLength);
bytes_left -= httpc->async_data->inet_buffers.dwBufferLength;
buf += httpc->async_data->inet_buffers.dwBufferLength;
}
+
+ HeapFree(GetProcessHeap(), 0, httpc->async_data->inet_buffers.lpvBuffer);
+ httpc->async_data->inet_buffers.lpvBuffer = NULL;
+
TRACE("%p %p %u -> %u\n", httpc->out_request, buffer, count, status);
return status == RPC_S_OK ? count : -1;
}
More information about the wine-cvs
mailing list