void IOV_WriteBufToIov(const uint8* bufIn, // IN size_t bufSize, // IN struct iovec* entries, // OUT int numEntries) // IN { size_t count = 0; int i; ASSERT(entries); ASSERT_BUG(29009, bufIn); for (i = 0; i < numEntries; i++) { size_t numBytes; ASSERT(entries[i].iov_base); ASSERT(entries[i].iov_base != LAZY_ALLOC_MAGIC); numBytes = MIN(bufSize - count, entries[i].iov_len); Util_Memcpy(entries[i].iov_base, &bufIn[count], numBytes); count += numBytes; if (count >= bufSize) { return; } ASSERT_NOT_IMPLEMENTED(count <= bufSize); } }
size_t IOV_WriteBufToIovPlus(uint8* bufIn, // IN size_t bufSize, // IN struct iovec* entries, // OUT int numEntries, // IN size_t iovOffset) // IN { size_t entryLen, entryOffset; size_t count = bufSize; int i; ASSERT_BUG(29009, bufIn); i = IOVFindFirstEntryOffset(entries, numEntries, iovOffset, &entryOffset); for (; count && (i < numEntries); i++) { char *base = (char *)(entries[i].iov_base) + entryOffset; size_t iov_len = entries[i].iov_len; ASSERT_BUG(33859, entries[i].iov_base || entries[i].iov_len == 0); ASSERT(entries[i].iov_base != LAZY_ALLOC_MAGIC); if (iov_len <= 0) { continue; } entryLen = MIN(count, iov_len - entryOffset); Util_Memcpy(base, bufIn, entryLen); count -= entryLen; bufIn += entryLen; entryOffset = 0; } ASSERT(count <= bufSize); return bufSize - count; }
wchar_t * Str_Wcscpy(wchar_t *buf, // OUT const wchar_t *src, // IN size_t maxSize) // IN: Size of buf, in wide-characters. { uint32 *stack = (uint32 *)&buf; size_t len; len = wcslen(src); if (len >= maxSize) { Panic("%s:%d Buffer too small 0x%x\n", __FILE__, __LINE__, stack[-1]); ASSERT_BUG(5686, FALSE); } return memcpy(buf, src, (len + 1)*sizeof(wchar_t)); }
char * Str_Strcpy(char *buf, // OUT const char *src, // IN size_t maxSize) // IN { uint32 *stack = (uint32 *)&buf; size_t len; ASSERT(buf != NULL); ASSERT(src != NULL); len = strlen(src); if (len >= maxSize) { Panic("%s:%d Buffer too small 0x%x\n", __FILE__, __LINE__, stack[-1]); ASSERT_BUG(5686, FALSE); } return memcpy(buf, src, len + 1); }