Janitorial: Get rid of strncpy/strncpyW.
This commit is contained in:
parent
4a8ce2ae41
commit
a667d536b9
|
@ -72,7 +72,7 @@ static BOOL CALLBACK MSACM_FillFormatTagsCB(HACMDRIVERID hadid,
|
|||
|
||||
if (acmDriverOpen(&had, hadid, 0) == MMSYSERR_NOERROR) {
|
||||
ACMFORMATDETAILSA afd;
|
||||
unsigned int i, idx;
|
||||
unsigned int i, len;
|
||||
MMRESULT mmr;
|
||||
char buffer[ACMFORMATDETAILS_FORMAT_CHARS+16];
|
||||
|
||||
|
@ -88,10 +88,9 @@ static BOOL CALLBACK MSACM_FillFormatTagsCB(HACMDRIVERID hadid,
|
|||
afd.dwFormatIndex = i;
|
||||
mmr = acmFormatDetailsA(had, &afd, ACM_FORMATDETAILSF_INDEX);
|
||||
if (mmr == MMSYSERR_NOERROR) {
|
||||
strncpy(buffer, afd.szFormat, ACMFORMATTAGDETAILS_FORMATTAG_CHARS);
|
||||
for (idx = strlen(buffer);
|
||||
idx < ACMFORMATTAGDETAILS_FORMATTAG_CHARS; idx++)
|
||||
buffer[idx] = ' ';
|
||||
lstrcpynA(buffer, afd.szFormat, ACMFORMATTAGDETAILS_FORMATTAG_CHARS + 1);
|
||||
len = strlen(buffer);
|
||||
memset(buffer+len, ' ', ACMFORMATTAGDETAILS_FORMATTAG_CHARS - len);
|
||||
wsprintfA(buffer + ACMFORMATTAGDETAILS_FORMATTAG_CHARS,
|
||||
"%d Ko/s",
|
||||
(afd.pwfx->nAvgBytesPerSec + 512) / 1024);
|
||||
|
|
|
@ -338,6 +338,7 @@ DWORD WINAPI GetModuleBaseNameW(HANDLE hProcess, HMODULE hModule,
|
|||
{
|
||||
WCHAR tmp[MAX_PATH];
|
||||
WCHAR* ptr;
|
||||
int ptrlen;
|
||||
|
||||
if(!lpBaseName || !nSize) {
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
|
@ -349,8 +350,9 @@ DWORD WINAPI GetModuleBaseNameW(HANDLE hProcess, HMODULE hModule,
|
|||
return 0;
|
||||
TRACE("%s\n", debugstr_w(tmp));
|
||||
if ((ptr = strrchrW(tmp, '\\')) != NULL) ptr++; else ptr = tmp;
|
||||
strncpyW(lpBaseName, ptr, nSize);
|
||||
return min(strlenW(ptr), nSize);
|
||||
ptrlen = strlenW(ptr);
|
||||
memcpy(lpBaseName, ptr, min(ptrlen+1,nSize) * sizeof(WCHAR));
|
||||
return min(ptrlen, nSize);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
|
|
@ -163,7 +163,7 @@ static void TEXT_Ellipsify (HDC hdc, WCHAR *str, unsigned int max_len,
|
|||
/* Now this should take only a couple iterations at most. */
|
||||
for ( ; ; )
|
||||
{
|
||||
strncpyW (str + *len_str, ELLIPSISW, len_ellipsis);
|
||||
memcpy(str + *len_str, ELLIPSISW, len_ellipsis*sizeof(WCHAR));
|
||||
|
||||
if (!GetTextExtentExPointW (hdc, str, *len_str + len_ellipsis, width,
|
||||
NULL, NULL, size)) break;
|
||||
|
@ -178,7 +178,7 @@ static void TEXT_Ellipsify (HDC hdc, WCHAR *str, unsigned int max_len,
|
|||
|
||||
if (modstr)
|
||||
{
|
||||
strncpyW (modstr, str, *len_str);
|
||||
memcpy (modstr, str, *len_str * sizeof(WCHAR));
|
||||
*(str+*len_str) = '\0';
|
||||
}
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ static void TEXT_PathEllipsify (HDC hdc, WCHAR *str, unsigned int max_len,
|
|||
|
||||
/* overlap-safe movement to the right */
|
||||
memmove (lastSlash+len_ellipsis, lastSlash, len_trailing * sizeof(WCHAR));
|
||||
strncpyW (lastSlash, ELLIPSISW, len_ellipsis);
|
||||
memcpy (lastSlash, ELLIPSISW, len_ellipsis*sizeof(WCHAR));
|
||||
len_trailing += len_ellipsis;
|
||||
/* From this point on lastSlash actually points to the ellipsis in front
|
||||
* of the last slash and len_trailing includes the ellipsis
|
||||
|
|
|
@ -354,16 +354,18 @@ BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int f
|
|||
}
|
||||
else if (flags & MSG_PEEK && peek_msg)
|
||||
{
|
||||
if (len < strlen(peek_msg))
|
||||
size_t peek_msg_len = strlen(peek_msg);
|
||||
if (len < peek_msg_len)
|
||||
FIXME("buffer isn't big enough. Do the expect us to wrap?\n");
|
||||
strncpy(buf, peek_msg, len);
|
||||
*recvd = (strlen(peek_msg) <= len ? strlen(peek_msg) : len);
|
||||
memcpy(buf, peek_msg, min(len,peek_msg_len+1));
|
||||
*recvd = min(len, peek_msg_len);
|
||||
return TRUE;
|
||||
}
|
||||
else if (peek_msg)
|
||||
{
|
||||
strncpy(buf, peek_msg, len);
|
||||
peek_msg += *recvd = min(len, strlen(peek_msg));
|
||||
size_t peek_msg_len = strlen(peek_msg);
|
||||
memcpy(buf, peek_msg, min(len,peek_msg_len+1));
|
||||
peek_msg += *recvd = min(len, peek_msg_len);
|
||||
if (*peek_msg == '\0' || *(peek_msg - 1) == '\0')
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, peek_msg_mem);
|
||||
|
@ -383,7 +385,7 @@ BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int f
|
|||
}
|
||||
else
|
||||
{
|
||||
strncpy(peek_msg, buf, *recvd);
|
||||
memcpy(peek_msg, buf, *recvd);
|
||||
peek_msg[*recvd] = '\0';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue