oleaut32: Add a function to grow the marshal state buffer to a specified size.

This commit is contained in:
Huw Davies 2006-05-10 11:55:37 +01:00 committed by Alexandre Julliard
parent a9c5fd2612
commit d0bdf685f5
1 changed files with 29 additions and 13 deletions

View File

@ -68,19 +68,35 @@ static char *relaystr(WCHAR *in) {
} }
static HRESULT static HRESULT
xbuf_add(marshal_state *buf, LPBYTE stuff, DWORD size) { xbuf_resize(marshal_state *buf, DWORD newsize)
while (buf->size - buf->curoff < size) { {
if (buf->base) { if(buf->size >= newsize)
buf->size += 100; return S_FALSE;
buf->base = HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,buf->base,buf->size);
if (!buf->base) if(buf->base)
return E_OUTOFMEMORY; {
} else { buf->base = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, buf->base, newsize);
buf->base = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,32); if(!buf->base)
buf->size = 32; return E_OUTOFMEMORY;
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); memcpy(buf->base+buf->curoff,stuff,size);
buf->curoff += size; buf->curoff += size;