Author: weiden Date: Mon Nov 19 01:53:30 2007 New Revision: 30561
URL: http://svn.reactos.org/svn/reactos?rev=30561&view=rev Log: Get rid of string pool helper routines
Removed: trunk/reactos/dll/win32/user32/include/strpool.h trunk/reactos/dll/win32/user32/misc/strpool.c Modified: trunk/reactos/dll/win32/user32/include/user32p.h trunk/reactos/dll/win32/user32/misc/dllmain.c trunk/reactos/dll/win32/user32/misc/wsprintf.c trunk/reactos/dll/win32/user32/user32.rbuild trunk/reactos/dll/win32/user32/windows/class.c trunk/reactos/dll/win32/user32/windows/clipboard.c trunk/reactos/dll/win32/user32/windows/messagebox.c
Removed: trunk/reactos/dll/win32/user32/include/strpool.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/include/st... ============================================================================== --- trunk/reactos/dll/win32/user32/include/strpool.h (original) +++ trunk/reactos/dll/win32/user32/include/strpool.h (removed) @@ -1,35 +1,0 @@ -// strpool.h - -#ifndef __USER32_INTERNAL_STRING_POOL_H -#define __USER32_INTERNAL_STRING_POOL_H - -extern HANDLE hProcessHeap; - -PVOID -HEAP_alloc ( DWORD len ); - -VOID -HEAP_free ( LPVOID memory ); - -LPWSTR -HEAP_strdupW ( LPCWSTR src, DWORD len ); - -NTSTATUS -HEAP_strcpyWtoA ( LPSTR lpszA, LPCWSTR lpszW, DWORD len ); - -NTSTATUS -HEAP_strcpyAtoW ( LPWSTR lpszW, LPCSTR lpszA, DWORD len ); - -NTSTATUS -HEAP_strdupWtoA ( LPSTR* ppszA, LPCWSTR lpszW, DWORD len ); - -NTSTATUS -HEAP_strdupAtoW ( LPWSTR* ppszW, LPCSTR lpszA, UINT* NewLen ); - -char* -heap_string_poolA ( const wchar_t* pstrW, DWORD length ); - -wchar_t* -heap_string_poolW ( const wchar_t* pstrWSrc, DWORD length ); - -#endif//__USER32_INTERNAL_STRING_POOL_H
Modified: trunk/reactos/dll/win32/user32/include/user32p.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/include/us... ============================================================================== --- trunk/reactos/dll/win32/user32/include/user32p.h (original) +++ trunk/reactos/dll/win32/user32/include/user32p.h Mon Nov 19 01:53:30 2007 @@ -22,7 +22,6 @@ #include "regcontrol.h" #include "resource.h" #include "scroll.h" -#include "strpool.h" #include "window.h" #include "winpos.h" #include "winsta.h"
Modified: trunk/reactos/dll/win32/user32/misc/dllmain.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/misc/dllma... ============================================================================== --- trunk/reactos/dll/win32/user32/misc/dllmain.c (original) +++ trunk/reactos/dll/win32/user32/misc/dllmain.c Mon Nov 19 01:53:30 2007 @@ -111,7 +111,6 @@ return FALSE; }
- hProcessHeap = RtlGetProcessHeap(); if (!Init()) return FALSE; if (!InitThread())
Removed: trunk/reactos/dll/win32/user32/misc/strpool.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/misc/strpo... ============================================================================== --- trunk/reactos/dll/win32/user32/misc/strpool.c (original) +++ trunk/reactos/dll/win32/user32/misc/strpool.c (removed) @@ -1,164 +1,0 @@ -// strpool.c - -#include <user32.h> - -#include <wine/debug.h> - -typedef struct tagHEAP_STRING_POOLA -{ - char* data; - struct tagHEAP_STRING_POOLA* next; -} HEAP_STRING_POOLA, *PHEAP_STRING_POOLA; - -typedef struct tagHEAP_STRING_POOLW -{ - wchar_t* data; - struct tagHEAP_STRING_POOLW* next; -} HEAP_STRING_POOLW, *PHEAP_STRING_POOLW; - -PHEAP_STRING_POOLA heap_string_Apool = NULL; - -PHEAP_STRING_POOLW heap_string_Wpool = NULL; - -HANDLE hProcessHeap = NULL; - -PVOID -HEAP_alloc ( DWORD len ) -{ - return RtlAllocateHeap ( hProcessHeap, 0, len ); -} - -VOID -HEAP_free ( LPVOID memory ) -{ - RtlFreeHeap ( hProcessHeap, 0, memory ); -} - -LPWSTR -HEAP_strdupW ( LPCWSTR src, DWORD len ) -{ - LPWSTR dst; - - if ( !src ) - return NULL; - - dst = HEAP_alloc ( (len+1) * sizeof(WCHAR) ); - if ( !dst ) - return NULL; - memcpy ( dst, src, (len+1)*sizeof(WCHAR) ); - return dst; -} - -NTSTATUS -HEAP_strcpyWtoA ( LPSTR lpszA, LPCWSTR lpszW, DWORD len ) -{ - NTSTATUS Status = - RtlUnicodeToMultiByteN ( lpszA, len, NULL, (LPWSTR)lpszW, len*sizeof(WCHAR) ); - lpszA[len] = '\0'; - return Status; -} - -NTSTATUS -HEAP_strcpyAtoW ( LPWSTR lpszW, LPCSTR lpszA, DWORD len ) -{ - NTSTATUS Status = - RtlMultiByteToUnicodeN ( lpszW, len*sizeof(WCHAR), NULL, (LPSTR)lpszA, len ); - lpszW[len] = L'\0'; - return Status; -} - -NTSTATUS -HEAP_strdupWtoA ( LPSTR* ppszA, LPCWSTR lpszW, DWORD len ) -{ - *ppszA = NULL; - - if ( !lpszW ) - return STATUS_SUCCESS; - - *ppszA = HEAP_alloc ( len + 1 ); - - if ( !*ppszA ) - return STATUS_NO_MEMORY; - - return HEAP_strcpyWtoA ( *ppszA, lpszW, len ); -} - -NTSTATUS -HEAP_strdupAtoW ( LPWSTR* ppszW, LPCSTR lpszA, UINT* NewLen ) -{ - ULONG len; - - *ppszW = NULL; - - if ( !lpszA ) - return STATUS_SUCCESS; - - len = lstrlenA ( lpszA ); - - *ppszW = HEAP_alloc ( (len+1) * sizeof(WCHAR) ); - - if ( !*ppszW ) - return STATUS_NO_MEMORY; - - if ( NewLen ) *NewLen = (UINT)len; - - return HEAP_strcpyAtoW ( *ppszW, lpszA, len ); -} - -char* heap_string_poolA ( const wchar_t* pstrW, DWORD length ) -{ - PHEAP_STRING_POOLA pPoolEntry = heap_string_Apool; - char* pstrA = NULL; - HEAP_strdupWtoA ( &pstrA, pstrW, length ); - if ( !pstrA ) - return NULL; - while ( pPoolEntry ) - { - if ( !strcmp ( pPoolEntry->data, pstrA ) ) - { - HEAP_free ( pstrA ); - return pPoolEntry->data; - } - pPoolEntry = pPoolEntry->next; - } - pPoolEntry = (PHEAP_STRING_POOLA)HEAP_alloc ( sizeof(HEAP_STRING_POOLA) ); - pPoolEntry->data = pstrA; - - // IMHO, synchronization is *not* needed here. This data is process- - // local, so the only possible contention is among threads. If a - // conflict does occur, the only problem will be a small memory - // leak that gets cleared up when the heap is destroyed by the - // process exiting. - pPoolEntry->next = heap_string_Apool; - heap_string_Apool = pPoolEntry; - return pPoolEntry->data; -} - -wchar_t* heap_string_poolW ( const wchar_t* pstrWSrc, DWORD length ) -{ - PHEAP_STRING_POOLW pPoolEntry = heap_string_Wpool; - wchar_t* pstrW = NULL; - pstrW = HEAP_strdupW ( (LPWSTR)pstrWSrc, length ); - if ( !pstrW ) - return NULL; - while ( pPoolEntry ) - { - if ( !wcscmp (pPoolEntry->data, pstrW ) ) - { - HEAP_free ( pstrW ); - return pPoolEntry->data; - } - pPoolEntry = pPoolEntry->next; - } - pPoolEntry = (PHEAP_STRING_POOLW)HEAP_alloc ( sizeof(HEAP_STRING_POOLW) ); - pPoolEntry->data = pstrW; - - // IMHO, synchronization is *not* needed here. This data is process- - // local, so the only possible contention is among threads. If a - // conflict does occur, the only problem will be a small memory - // leak that gets cleared up when the heap is destroyed by the - // process exiting. - pPoolEntry->next = heap_string_Wpool; - heap_string_Wpool = pPoolEntry; - return pPoolEntry->data; -}
Modified: trunk/reactos/dll/win32/user32/misc/wsprintf.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/misc/wspri... ============================================================================== --- trunk/reactos/dll/win32/user32/misc/wsprintf.c (original) +++ trunk/reactos/dll/win32/user32/misc/wsprintf.c Mon Nov 19 01:53:30 2007 @@ -598,11 +598,3 @@ } return Size; } -const LPWSTR strings[14] = {L"OK",L"Cancel",L"&Abort",L"&Retry",L"&Ignore",L"&Yes",L"&No",L"&Close",L"Help",L"&Try Again",L"&Continue"}; -/* - * @implemented - */ -LPWSTR STDCALL MB_GetString(DWORD string) -{ - return heap_string_poolW(strings[string],wcslen(strings[string])); -}
Modified: trunk/reactos/dll/win32/user32/user32.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/user32.rbu... ============================================================================== --- trunk/reactos/dll/win32/user32/user32.rbuild (original) +++ trunk/reactos/dll/win32/user32/user32.rbuild Mon Nov 19 01:53:30 2007 @@ -41,7 +41,6 @@ <file>misc.c</file> <file>object.c</file> <file>resources.c</file> - <file>strpool.c</file> <file>stubs.c</file> <file>timer.c</file> <file>winhelp.c</file>
Modified: trunk/reactos/dll/win32/user32/windows/class.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/cl... ============================================================================== --- trunk/reactos/dll/win32/user32/windows/class.c (original) +++ trunk/reactos/dll/win32/user32/windows/class.c Mon Nov 19 01:53:30 2007 @@ -1200,7 +1200,6 @@ HINSTANCE hInstance) { UNICODE_STRING ClassName = {0}; - NTSTATUS Status; BOOL Ret;
TRACE("class/atom: %s/%04x %p\n", @@ -1210,15 +1209,12 @@
if (!IS_ATOM(lpClassName)) { - Status = HEAP_strdupAtoW(&ClassName.Buffer, lpClassName, NULL); - if (!NT_SUCCESS(Status)) - { - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; - } - - RtlInitUnicodeString(&ClassName, - ClassName.Buffer); + if (!RtlCreateUnicodeStringFromAsciiz(&ClassName, + lpClassName)) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } } else ClassName.Buffer = (PWSTR)((ULONG_PTR)lpClassName); @@ -1226,8 +1222,8 @@ Ret = NtUserUnregisterClass(&ClassName, hInstance);
- if(!IS_ATOM(lpClassName) && ClassName.Buffer != NULL) - HEAP_free(ClassName.Buffer); + if (!IS_ATOM(lpClassName)) + RtlFreeUnicodeString(&ClassName);
return Ret; }
Modified: trunk/reactos/dll/win32/user32/windows/clipboard.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/cl... ============================================================================== --- trunk/reactos/dll/win32/user32/windows/clipboard.c (original) +++ trunk/reactos/dll/win32/user32/windows/clipboard.c Mon Nov 19 01:53:30 2007 @@ -114,14 +114,14 @@ { LPWSTR lpBuffer; UNICODE_STRING FormatName; + ANSI_STRING FormatNameA; INT Length; ANSI_STRING ClassName;
ClassName.MaximumLength = cchMaxCount; ClassName.Buffer = lpszFormatName;
- lpBuffer = HEAP_alloc(cchMaxCount * sizeof(WCHAR)); - + lpBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, cchMaxCount * sizeof(WCHAR)); if (!lpBuffer) { SetLastError(ERROR_OUTOFMEMORY); @@ -135,9 +135,18 @@ /* we need a UNICODE string */ Length = NtUserGetClipboardFormatName(format, &FormatName, cchMaxCount);
- HEAP_strcpyWtoA(lpszFormatName, FormatName.Buffer, Length); - - return strlen(lpszFormatName); + if (Length != 0) + { + FormatNameA.Length = 0; + FormatNameA.MaximumLength = cchMaxCount; + FormatNameA.Buffer = lpszFormatName; + + RtlUnicodeStringToAnsiString(&FormatNameA, &FormatName, FALSE); + + return FormatNameA.Length; + } + + return 0; }
/*
Modified: trunk/reactos/dll/win32/user32/windows/messagebox.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/me... ============================================================================== --- trunk/reactos/dll/win32/user32/windows/messagebox.c (original) +++ trunk/reactos/dll/win32/user32/windows/messagebox.c Mon Nov 19 01:53:30 2007 @@ -922,4 +922,14 @@ #endif }
+ +/* + * @implemented + */ +LPWSTR STDCALL MB_GetString(DWORD string) +{ + UNIMPLEMENTED; + return NULL; +} + /* EOF */