Module: wine Branch: refs/heads/master Commit: d0bdf685f56414de7d4d1a0254d3d2d6ef88e67a URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=d0bdf685f56414de7d4d1a02...
Author: Huw Davies huw@codeweavers.com Date: Wed May 10 11:55:37 2006 +0100
oleaut32: Add a function to grow the marshal state buffer to a specified size.
---
dlls/oleaut32/tmarshal.c | 42 +++++++++++++++++++++++++++++------------- 1 files changed, 29 insertions(+), 13 deletions(-)
diff --git a/dlls/oleaut32/tmarshal.c b/dlls/oleaut32/tmarshal.c index 249524a..0a6e939 100644 --- a/dlls/oleaut32/tmarshal.c +++ b/dlls/oleaut32/tmarshal.c @@ -68,19 +68,35 @@ static char *relaystr(WCHAR *in) { }
static HRESULT -xbuf_add(marshal_state *buf, LPBYTE stuff, DWORD size) { - while (buf->size - buf->curoff < size) { - if (buf->base) { - buf->size += 100; - buf->base = HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,buf->base,buf->size); - if (!buf->base) - return E_OUTOFMEMORY; - } else { - buf->base = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,32); - buf->size = 32; - if (!buf->base) - return E_OUTOFMEMORY; - } +xbuf_resize(marshal_state *buf, DWORD newsize) +{ + if(buf->size >= newsize) + return S_FALSE; + + if(buf->base) + { + buf->base = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, buf->base, newsize); + if(!buf->base) + return E_OUTOFMEMORY; + } + else + { + buf->base = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, newsize); + if(!buf->base) + return E_OUTOFMEMORY; + } + return S_OK; +} + +static HRESULT +xbuf_add(marshal_state *buf, LPBYTE stuff, DWORD size) +{ + HRESULT hr; + + if(buf->size - buf->curoff < size) + { + hr = xbuf_resize(buf, buf->size + size + 100); + if(FAILED(hr)) return hr; } memcpy(buf->base+buf->curoff,stuff,size); buf->curoff += size;