mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 01:15:09 +00:00
Get rid of string pool helper routines
svn path=/trunk/; revision=30561
This commit is contained in:
parent
35f10174b2
commit
ab4e7b1729
9 changed files with 29 additions and 224 deletions
|
@ -1,35 +0,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
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include "regcontrol.h"
|
#include "regcontrol.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "scroll.h"
|
#include "scroll.h"
|
||||||
#include "strpool.h"
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include "winpos.h"
|
#include "winpos.h"
|
||||||
#include "winsta.h"
|
#include "winsta.h"
|
||||||
|
|
|
@ -111,7 +111,6 @@ DllMain(
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
hProcessHeap = RtlGetProcessHeap();
|
|
||||||
if (!Init())
|
if (!Init())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!InitThread())
|
if (!InitThread())
|
||||||
|
|
|
@ -1,164 +0,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;
|
|
||||||
}
|
|
|
@ -598,11 +598,3 @@ DWORD STDCALL MBToWCSEx(WORD CodePage,LPSTR MBString,LONG MBSize,LPWSTR *Unicode
|
||||||
}
|
}
|
||||||
return Size;
|
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]));
|
|
||||||
}
|
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
<file>misc.c</file>
|
<file>misc.c</file>
|
||||||
<file>object.c</file>
|
<file>object.c</file>
|
||||||
<file>resources.c</file>
|
<file>resources.c</file>
|
||||||
<file>strpool.c</file>
|
|
||||||
<file>stubs.c</file>
|
<file>stubs.c</file>
|
||||||
<file>timer.c</file>
|
<file>timer.c</file>
|
||||||
<file>winhelp.c</file>
|
<file>winhelp.c</file>
|
||||||
|
|
|
@ -1200,7 +1200,6 @@ UnregisterClassA(
|
||||||
HINSTANCE hInstance)
|
HINSTANCE hInstance)
|
||||||
{
|
{
|
||||||
UNICODE_STRING ClassName = {0};
|
UNICODE_STRING ClassName = {0};
|
||||||
NTSTATUS Status;
|
|
||||||
BOOL Ret;
|
BOOL Ret;
|
||||||
|
|
||||||
TRACE("class/atom: %s/%04x %p\n",
|
TRACE("class/atom: %s/%04x %p\n",
|
||||||
|
@ -1210,15 +1209,12 @@ UnregisterClassA(
|
||||||
|
|
||||||
if (!IS_ATOM(lpClassName))
|
if (!IS_ATOM(lpClassName))
|
||||||
{
|
{
|
||||||
Status = HEAP_strdupAtoW(&ClassName.Buffer, lpClassName, NULL);
|
if (!RtlCreateUnicodeStringFromAsciiz(&ClassName,
|
||||||
if (!NT_SUCCESS(Status))
|
lpClassName))
|
||||||
{
|
{
|
||||||
SetLastError(RtlNtStatusToDosError(Status));
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
return FALSE;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlInitUnicodeString(&ClassName,
|
|
||||||
ClassName.Buffer);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ClassName.Buffer = (PWSTR)((ULONG_PTR)lpClassName);
|
ClassName.Buffer = (PWSTR)((ULONG_PTR)lpClassName);
|
||||||
|
@ -1226,8 +1222,8 @@ UnregisterClassA(
|
||||||
Ret = NtUserUnregisterClass(&ClassName,
|
Ret = NtUserUnregisterClass(&ClassName,
|
||||||
hInstance);
|
hInstance);
|
||||||
|
|
||||||
if(!IS_ATOM(lpClassName) && ClassName.Buffer != NULL)
|
if (!IS_ATOM(lpClassName))
|
||||||
HEAP_free(ClassName.Buffer);
|
RtlFreeUnicodeString(&ClassName);
|
||||||
|
|
||||||
return Ret;
|
return Ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,14 +114,14 @@ GetClipboardFormatNameA(UINT format, LPSTR lpszFormatName, int cchMaxCount)
|
||||||
{
|
{
|
||||||
LPWSTR lpBuffer;
|
LPWSTR lpBuffer;
|
||||||
UNICODE_STRING FormatName;
|
UNICODE_STRING FormatName;
|
||||||
|
ANSI_STRING FormatNameA;
|
||||||
INT Length;
|
INT Length;
|
||||||
ANSI_STRING ClassName;
|
ANSI_STRING ClassName;
|
||||||
|
|
||||||
ClassName.MaximumLength = cchMaxCount;
|
ClassName.MaximumLength = cchMaxCount;
|
||||||
ClassName.Buffer = lpszFormatName;
|
ClassName.Buffer = lpszFormatName;
|
||||||
|
|
||||||
lpBuffer = HEAP_alloc(cchMaxCount * sizeof(WCHAR));
|
lpBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, cchMaxCount * sizeof(WCHAR));
|
||||||
|
|
||||||
if (!lpBuffer)
|
if (!lpBuffer)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_OUTOFMEMORY);
|
SetLastError(ERROR_OUTOFMEMORY);
|
||||||
|
@ -135,9 +135,18 @@ GetClipboardFormatNameA(UINT format, LPSTR lpszFormatName, int cchMaxCount)
|
||||||
/* we need a UNICODE string */
|
/* we need a UNICODE string */
|
||||||
Length = NtUserGetClipboardFormatName(format, &FormatName, cchMaxCount);
|
Length = NtUserGetClipboardFormatName(format, &FormatName, cchMaxCount);
|
||||||
|
|
||||||
HEAP_strcpyWtoA(lpszFormatName, FormatName.Buffer, Length);
|
if (Length != 0)
|
||||||
|
{
|
||||||
|
FormatNameA.Length = 0;
|
||||||
|
FormatNameA.MaximumLength = cchMaxCount;
|
||||||
|
FormatNameA.Buffer = lpszFormatName;
|
||||||
|
|
||||||
return strlen(lpszFormatName);
|
RtlUnicodeStringToAnsiString(&FormatNameA, &FormatName, FALSE);
|
||||||
|
|
||||||
|
return FormatNameA.Length;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -922,4 +922,14 @@ MessageBeep(UINT uType)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
LPWSTR STDCALL MB_GetString(DWORD string)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
Loading…
Reference in a new issue