Module: wine Branch: master Commit: 33ce8e046d519303bc561416fb4e2078dbef8178 URL: https://gitlab.winehq.org/wine/wine/-/commit/33ce8e046d519303bc561416fb4e207...
Author: Alex Henrie alexhenrie24@gmail.com Date: Sun Sep 24 12:24:10 2023 -0600
regedit: Use the wcsdup function instead or reimplementing it.
---
programs/regedit/edit.c | 3 +-- programs/regedit/listview.c | 11 ++--------- programs/regedit/regproc.c | 11 +++-------- 3 files changed, 6 insertions(+), 19 deletions(-)
diff --git a/programs/regedit/edit.c b/programs/regedit/edit.c index 947a6071e0f..b92d1c615b3 100644 --- a/programs/regedit/edit.c +++ b/programs/regedit/edit.c @@ -637,8 +637,7 @@ BOOL RenameKey(HWND hwnd, HKEY hRootKey, LPCWSTR keyPath, LPCWSTR newName) } else { LPWSTR srcSubKey_copy;
- parentPath = malloc((lstrlenW(keyPath) + 1) * sizeof(WCHAR)); - lstrcpyW(parentPath, keyPath); + parentPath = wcsdup(keyPath); srcSubKey_copy = wcsrchr(parentPath, '\'); *srcSubKey_copy = 0; srcSubKey = srcSubKey_copy + 1; diff --git a/programs/regedit/listview.c b/programs/regedit/listview.c index c7a301929c2..757ce41855c 100644 --- a/programs/regedit/listview.c +++ b/programs/regedit/listview.c @@ -73,8 +73,7 @@ BOOL update_listview_path(const WCHAR *path) { free(g_currentPath);
- g_currentPath = malloc((lstrlenW(path) + 1) * sizeof(WCHAR)); - lstrcpyW(g_currentPath, path); + g_currentPath = wcsdup(path);
return TRUE; } @@ -154,13 +153,7 @@ int AddEntryToList(HWND hwndLV, WCHAR *Name, DWORD dwValType, void *ValBuf, DWOR linfo = malloc(sizeof(LINE_INFO)); linfo->dwValType = dwValType; linfo->val_len = dwCount; - - if (Name) - { - linfo->name = malloc((lstrlenW(Name) + 1) * sizeof(WCHAR)); - lstrcpyW(linfo->name, Name); - } - else linfo->name = NULL; + linfo->name = wcsdup(Name);
if (ValBuf && dwCount) { diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c index 199cd3b6d80..15a64fdf97d 100644 --- a/programs/regedit/regproc.c +++ b/programs/regedit/regproc.c @@ -447,10 +447,7 @@ static LONG open_key(struct parser *parser, WCHAR *path) KEY_ALL_ACCESS, NULL, &parser->hkey, NULL);
if (res == ERROR_SUCCESS) - { - parser->key_name = malloc((lstrlenW(path) + 1) * sizeof(WCHAR)); - lstrcpyW(parser->key_name, path); - } + parser->key_name = wcsdup(path); else parser->hkey = NULL;
@@ -699,8 +696,7 @@ static WCHAR *quoted_value_name_state(struct parser *parser, WCHAR *pos) goto invalid;
/* copy the value name in case we need to parse multiple lines and the buffer is overwritten */ - parser->value_name = malloc((lstrlenW(val_name) + 1) * sizeof(WCHAR)); - lstrcpyW(parser->value_name, val_name); + parser->value_name = wcsdup(val_name);
set_state(parser, DATA_START); return p; @@ -1486,8 +1482,7 @@ static BOOL export_all(WCHAR *file_name, WCHAR *path, BOOL unicode) return FALSE; }
- class_name = malloc((lstrlenW(reg_class_namesW[i]) + 1) * sizeof(WCHAR)); - lstrcpyW(class_name, reg_class_namesW[i]); + class_name = wcsdup(reg_class_namesW[i]);
export_registry_data(fp, classes[i], class_name, unicode);