reg: Replace the 'reg_count' variable name with context-specific names.
Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
08786274e2
commit
2c73949a46
|
@ -48,11 +48,12 @@ static inline BYTE hexchar_to_byte(WCHAR ch)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LPBYTE get_regdata(const WCHAR *data, DWORD reg_type, WCHAR separator, DWORD *reg_count)
|
static BYTE *get_regdata(const WCHAR *data, DWORD reg_type, WCHAR separator, DWORD *size_bytes)
|
||||||
{
|
{
|
||||||
static const WCHAR empty;
|
static const WCHAR empty;
|
||||||
LPBYTE out_data = NULL;
|
LPBYTE out_data = NULL;
|
||||||
*reg_count = 0;
|
|
||||||
|
*size_bytes = 0;
|
||||||
|
|
||||||
if (!data) data = ∅
|
if (!data) data = ∅
|
||||||
|
|
||||||
|
@ -62,8 +63,8 @@ static LPBYTE get_regdata(const WCHAR *data, DWORD reg_type, WCHAR separator, DW
|
||||||
case REG_SZ:
|
case REG_SZ:
|
||||||
case REG_EXPAND_SZ:
|
case REG_EXPAND_SZ:
|
||||||
{
|
{
|
||||||
*reg_count = (lstrlenW(data) + 1) * sizeof(WCHAR);
|
*size_bytes = (lstrlenW(data) + 1) * sizeof(WCHAR);
|
||||||
out_data = malloc(*reg_count);
|
out_data = malloc(*size_bytes);
|
||||||
lstrcpyW((LPWSTR)out_data,data);
|
lstrcpyW((LPWSTR)out_data,data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -78,8 +79,8 @@ static LPBYTE get_regdata(const WCHAR *data, DWORD reg_type, WCHAR separator, DW
|
||||||
output_message(STRING_MISSING_INTEGER);
|
output_message(STRING_MISSING_INTEGER);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*reg_count = sizeof(DWORD);
|
*size_bytes = sizeof(DWORD);
|
||||||
out_data = malloc(*reg_count);
|
out_data = malloc(*size_bytes);
|
||||||
((LPDWORD)out_data)[0] = val;
|
((LPDWORD)out_data)[0] = val;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -87,8 +88,8 @@ static LPBYTE get_regdata(const WCHAR *data, DWORD reg_type, WCHAR separator, DW
|
||||||
{
|
{
|
||||||
BYTE hex0, hex1;
|
BYTE hex0, hex1;
|
||||||
int i = 0, destByteIndex = 0, datalen = lstrlenW(data);
|
int i = 0, destByteIndex = 0, datalen = lstrlenW(data);
|
||||||
*reg_count = ((datalen + datalen % 2) / 2) * sizeof(BYTE);
|
*size_bytes = ((datalen + datalen % 2) / 2) * sizeof(BYTE);
|
||||||
out_data = malloc(*reg_count);
|
out_data = malloc(*size_bytes);
|
||||||
if(datalen % 2)
|
if(datalen % 2)
|
||||||
{
|
{
|
||||||
hex1 = hexchar_to_byte(data[i++]);
|
hex1 = hexchar_to_byte(data[i++]);
|
||||||
|
@ -139,7 +140,7 @@ static LPBYTE get_regdata(const WCHAR *data, DWORD reg_type, WCHAR separator, DW
|
||||||
buffer[destindex] = 0;
|
buffer[destindex] = 0;
|
||||||
if (destindex && buffer[destindex - 1])
|
if (destindex && buffer[destindex - 1])
|
||||||
buffer[++destindex] = 0;
|
buffer[++destindex] = 0;
|
||||||
*reg_count = (destindex + 1) * sizeof(WCHAR);
|
*size_bytes = (destindex + 1) * sizeof(WCHAR);
|
||||||
return (BYTE *)buffer;
|
return (BYTE *)buffer;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -164,7 +165,7 @@ static int run_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty,
|
||||||
if (value_name || value_empty || data)
|
if (value_name || value_empty || data)
|
||||||
{
|
{
|
||||||
DWORD reg_type;
|
DWORD reg_type;
|
||||||
DWORD reg_count = 0;
|
DWORD data_size = 0;
|
||||||
BYTE* reg_data = NULL;
|
BYTE* reg_data = NULL;
|
||||||
|
|
||||||
if (!force)
|
if (!force)
|
||||||
|
@ -194,13 +195,13 @@ static int run_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(reg_data = get_regdata(data, reg_type, separator, ®_count)))
|
if (!(reg_data = get_regdata(data, reg_type, separator, &data_size)))
|
||||||
{
|
{
|
||||||
RegCloseKey(hkey);
|
RegCloseKey(hkey);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegSetValueExW(hkey, value_name, 0, reg_type, reg_data, reg_count);
|
RegSetValueExW(hkey, value_name, 0, reg_type, reg_data, data_size);
|
||||||
free(reg_data);
|
free(reg_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue