Merge pull request #3991 from akallabeth/stream_string_helper

Stream convenience functions to read/write strings.
This commit is contained in:
Bernhard Miklautz 2017-11-27 11:49:46 +01:00 committed by GitHub
commit 50105c8157
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 32 additions and 0 deletions

View File

@ -332,6 +332,38 @@ static INLINE BOOL Stream_SafeSeek(wStream* s, size_t size)
return TRUE;
}
static INLINE BOOL Stream_Read_UTF16_String(wStream* s, WCHAR* dst, size_t length)
{
size_t x;
if (!s || !dst)
return FALSE;
if (Stream_GetRemainingLength(s) / sizeof(WCHAR) < length)
return FALSE;
for (x=0; x<length; x++)
Stream_Read_UINT16(s, dst[x]);
return TRUE;
}
static INLINE BOOL Stream_Write_UTF16_String(wStream* s, const WCHAR* src, size_t length)
{
size_t x;
if (!s || !src)
return FALSE;
if (Stream_GetRemainingCapacity(s) / sizeof(WCHAR) < length)
return FALSE;
for (x=0; x<length; x++)
Stream_Write_UINT16(s, src[x]);
return TRUE;
}
/* StreamPool */
struct _wStreamPool