[LOCALSPL_APITEST]
[reactos.git] / reactos / win32ss / printing / providers / localspl / tools.c
index fa0b733..10515db 100644 (file)
@@ -11,7 +11,7 @@
  * @name AllocAndRegQueryWSZ
  *
  * Queries a REG_SZ value in the registry, allocates memory for it and returns a buffer containing the value.
- * You have to free this buffer using HeapFree.
+ * You have to free this buffer using DllFreeSplMem.
  *
  * @param hKey
  * HKEY variable of the key opened with RegOpenKeyExW.
@@ -38,10 +38,10 @@ AllocAndRegQueryWSZ(HKEY hKey, PCWSTR pwszValueName)
     }
 
     // Allocate it.
-    pwszValue = HeapAlloc(hProcessHeap, 0, cbNeeded);
+    pwszValue = DllAllocSplMem(cbNeeded);
     if (!pwszValue)
     {
-        ERR("HeapAlloc failed with error %lu!\n", GetLastError());
+        ERR("DllAllocSplMem failed with error %lu!\n", GetLastError());
         return NULL;
     }
 
@@ -50,63 +50,31 @@ AllocAndRegQueryWSZ(HKEY hKey, PCWSTR pwszValueName)
     if (lStatus != ERROR_SUCCESS)
     {
         ERR("RegQueryValueExW failed with status %ld!\n", lStatus);
-        HeapFree(hProcessHeap, 0, pwszValue);
+        DllFreeSplMem(pwszValue);
         return NULL;
     }
 
     return pwszValue;
 }
 
-/**
- * @name DuplicateStringW
- *
- * Allocates memory for a Unicode string and copies the input string into it.
- * Equivalent of wcsdup, but the returned buffer must be freed with HeapFree instead of free.
- *
- * @param pwszInput
- * The input string to copy
- *
- * @return
- * Pointer to the copied string or NULL if no memory could be allocated.
- */
-PWSTR
-DuplicateStringW(PCWSTR pwszInput)
-{
-    DWORD cchInput;
-    PWSTR pwszOutput;
-
-    cchInput = wcslen(pwszInput);
-
-    pwszOutput = HeapAlloc(hProcessHeap, 0, (cchInput + 1) * sizeof(WCHAR));
-    if (!pwszOutput)
-    {
-        ERR("HeapAlloc failed with error %lu!\n", GetLastError());
-        return NULL;
-    }
-
-    CopyMemory(pwszOutput, pwszInput, (cchInput + 1) * sizeof(WCHAR));
-
-    return pwszOutput;
-}
-
 /**
  * @name GenericTableAllocateRoutine
  *
- * RTL_GENERIC_ALLOCATE_ROUTINE for all our RTL_GENERIC_TABLEs, using HeapAlloc.
+ * RTL_GENERIC_ALLOCATE_ROUTINE for all our RTL_GENERIC_TABLEs, using DllAllocSplMem.
  */
 PVOID NTAPI
 GenericTableAllocateRoutine(PRTL_GENERIC_TABLE Table, CLONG ByteSize)
 {
-    return HeapAlloc(hProcessHeap, 0, ByteSize);
+    return DllAllocSplMem(ByteSize);
 }
 
 /**
  * @name GenericTableFreeRoutine
  *
- * RTL_GENERIC_FREE_ROUTINE for all our RTL_GENERIC_TABLEs, using HeapFree.
+ * RTL_GENERIC_FREE_ROUTINE for all our RTL_GENERIC_TABLEs, using DllFreeSplMem.
  */
 VOID NTAPI
 GenericTableFreeRoutine(PRTL_GENERIC_TABLE Table, PVOID Buffer)
 {
-    HeapFree(hProcessHeap, 0, Buffer);
+    DllFreeSplMem(Buffer);
 }