From c87bac8d51b4044566978f166cb3fa82f18a1fa8 Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Thu, 22 Sep 2005 19:46:36 +0000 Subject: [PATCH] minor string initialization optimizations svn path=/trunk/; revision=17983 --- reactos/lib/advapi32/reg/reg.c | 75 ++++++++++++---------------------- 1 file changed, 25 insertions(+), 50 deletions(-) diff --git a/reactos/lib/advapi32/reg/reg.c b/reactos/lib/advapi32/reg/reg.c index 6ae65bdba4c..2377b54e2fb 100644 --- a/reactos/lib/advapi32/reg/reg.c +++ b/reactos/lib/advapi32/reg/reg.c @@ -405,20 +405,15 @@ RegCopyTreeA(IN HKEY hKeySrc, IN LPCSTR lpSubKey OPTIONAL, IN HKEY hKeyDest) { - UNICODE_STRING SubKeyName; + UNICODE_STRING SubKeyName = {0}; LONG Ret; - if (lpSubKey != NULL) + if (lpSubKey != NULL && + !RtlCreateUnicodeStringFromAsciiz(&SubKeyName, + (LPSTR)lpSubKey)) { - if (!RtlCreateUnicodeStringFromAsciiz(&SubKeyName, - (LPSTR)lpSubKey)) - { - return ERROR_NOT_ENOUGH_MEMORY; - } + return ERROR_NOT_ENOUGH_MEMORY; } - else - RtlInitUnicodeString(&SubKeyName, - NULL); Ret = RegCopyTreeW(hKeySrc, SubKeyName.Buffer, @@ -440,20 +435,15 @@ RegConnectRegistryA (IN LPCSTR lpMachineName, IN HKEY hKey, OUT PHKEY phkResult) { - UNICODE_STRING MachineName; + UNICODE_STRING MachineName = {0}; LONG Ret; - if (lpMachineName != NULL) + if (lpMachineName != NULL && + !RtlCreateUnicodeStringFromAsciiz(&MachineName, + (LPSTR)lpMachineName)) { - if (!RtlCreateUnicodeStringFromAsciiz(&MachineName, - (LPSTR)lpMachineName)) - { - return ERROR_NOT_ENOUGH_MEMORY; - } + return ERROR_NOT_ENOUGH_MEMORY; } - else - RtlInitUnicodeString(&MachineName, - NULL); Ret = RegConnectRegistryW(MachineName.Buffer, hKey, @@ -951,33 +941,23 @@ RegDeleteKeyValueA(IN HKEY hKey, IN LPCSTR lpSubKey OPTIONAL, IN LPCSTR lpValueName OPTIONAL) { - UNICODE_STRING SubKey, ValueName; + UNICODE_STRING SubKey = {0}, ValueName = {0}; LONG Ret; - if (lpSubKey != NULL) + if (lpSubKey != NULL && + !RtlCreateUnicodeStringFromAsciiz(&SubKey, + (LPSTR)lpSubKey)) { - if (!RtlCreateUnicodeStringFromAsciiz(&SubKey, - (LPSTR)lpSubKey)) - { - return ERROR_NOT_ENOUGH_MEMORY; - } + return ERROR_NOT_ENOUGH_MEMORY; } - else - RtlInitUnicodeString(&SubKey, - NULL); - if (lpValueName != NULL) + if (lpValueName != NULL && + !RtlCreateUnicodeStringFromAsciiz(&ValueName, + (LPSTR)lpValueName)) { - if (!RtlCreateUnicodeStringFromAsciiz(&ValueName, - (LPSTR)lpValueName)) - { - RtlFreeUnicodeString(&SubKey); - return ERROR_NOT_ENOUGH_MEMORY; - } + RtlFreeUnicodeString(&SubKey); + return ERROR_NOT_ENOUGH_MEMORY; } - else - RtlInitUnicodeString(&ValueName, - NULL); Ret = RegDeleteKeyValueW(hKey, SubKey.Buffer, @@ -1261,20 +1241,15 @@ LONG STDCALL RegDeleteTreeA(IN HKEY hKey, IN LPCSTR lpSubKey OPTIONAL) { - UNICODE_STRING SubKeyName; + UNICODE_STRING SubKeyName = {0}; LONG Ret; - if (lpSubKey != NULL) + if (lpSubKey != NULL && + !RtlCreateUnicodeStringFromAsciiz(&SubKeyName, + (LPSTR)lpSubKey)) { - if (!RtlCreateUnicodeStringFromAsciiz(&SubKeyName, - (LPSTR)lpSubKey)) - { - return ERROR_NOT_ENOUGH_MEMORY; - } + return ERROR_NOT_ENOUGH_MEMORY; } - else - RtlInitUnicodeString(&SubKeyName, - NULL); Ret = RegDeleteTreeW(hKey, SubKeyName.Buffer);