From 8310aab3e58b214c719dcd1aec84c0c4166fe120 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 28 Nov 2000 22:34:27 +0000 Subject: [PATCH] Made HEAP_strdup* functions inline (temporary). --- include/heap.h | 50 ++++++++++++++++++++++++++++++++++++++---- memory/heap.c | 69 ---------------------------------------------------------- 2 files changed, 46 insertions(+), 73 deletions(-) diff --git a/include/heap.h b/include/heap.h index f231f4d6c67..55177c881b4 100644 --- a/include/heap.h +++ b/include/heap.h @@ -10,6 +10,8 @@ #include "config.h" #include "winbase.h" +#include "winnls.h" +#include "wine/unicode.h" #include "wine/windef16.h" /* for SEGPTR */ extern HANDLE SystemHeap; @@ -17,10 +19,6 @@ extern HANDLE SegptrHeap; extern int HEAP_IsInsideHeap( HANDLE heap, DWORD flags, LPCVOID ptr ); extern SEGPTR HEAP_GetSegptr( HANDLE heap, DWORD flags, LPCVOID ptr ); -extern LPSTR HEAP_strdupA( HANDLE heap, DWORD flags, LPCSTR str ); -extern LPWSTR HEAP_strdupW( HANDLE heap, DWORD flags, LPCWSTR str ); -extern LPWSTR HEAP_strdupAtoW( HANDLE heap, DWORD flags, LPCSTR str ); -extern LPSTR HEAP_strdupWtoA( HANDLE heap, DWORD flags, LPCWSTR str ); extern BOOL HEAP_CreateSystemHeap(void); /* SEGPTR helper macros */ @@ -41,6 +39,50 @@ static inline SEGPTR WINE_UNUSED SEGPTR_Get(LPCVOID ptr) { #define SEGPTR_FREE(ptr) \ (HIWORD(ptr) ? HeapFree( SegptrHeap, 0, (ptr) ) : 0) + +/* strdup macros */ +/* DO NOT USE THEM!! they will go away soon */ + +inline static LPSTR HEAP_strdupA( HANDLE heap, DWORD flags, LPCSTR str ) +{ + INT len = strlen(str) + 1; + LPSTR p = HeapAlloc( heap, flags, len ); + if (p) memcpy( p, str, len ); + return p; +} + +inline static LPWSTR HEAP_strdupW( HANDLE heap, DWORD flags, LPCWSTR str ) +{ + INT len = strlenW(str) + 1; + LPWSTR p = HeapAlloc( heap, flags, len * sizeof(WCHAR) ); + if (p) memcpy( p, str, len * sizeof(WCHAR) ); + return p; +} + +inline static LPWSTR HEAP_strdupAtoW( HANDLE heap, DWORD flags, LPCSTR str ) +{ + LPWSTR ret; + INT len; + + if (!str) return NULL; + len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 ); + ret = HeapAlloc( heap, flags, len * sizeof(WCHAR) ); + if (ret) MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len ); + return ret; +} + +inline static LPSTR HEAP_strdupWtoA( HANDLE heap, DWORD flags, LPCWSTR str ) +{ + LPSTR ret; + INT len; + + if (!str) return NULL; + len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL ); + ret = HeapAlloc( heap, flags, len ); + if(ret) WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL ); + return ret; +} + /* system heap private data */ /* you must lock the system heap before using this structure */ typedef struct diff --git a/memory/heap.c b/memory/heap.c index a3e03956de0..f8a75e9e4d7 100644 --- a/memory/heap.c +++ b/memory/heap.c @@ -10,7 +10,6 @@ #include #include #include "wine/winbase16.h" -#include "wine/winestring.h" #include "wine/unicode.h" #include "selectors.h" #include "global.h" @@ -1663,74 +1662,6 @@ DWORD WINAPI GetProcessHeaps( DWORD count, HANDLE *heaps ) /*********************************************************************** - * HEAP_strdupA - */ -LPSTR HEAP_strdupA( HANDLE heap, DWORD flags, LPCSTR str ) -{ - LPSTR p = HeapAlloc( heap, flags, strlen(str) + 1 ); - if(p) { - SET_EIP(p); - strcpy( p, str ); - } - return p; -} - - -/*********************************************************************** - * HEAP_strdupW - */ -LPWSTR HEAP_strdupW( HANDLE heap, DWORD flags, LPCWSTR str ) -{ - INT len = strlenW(str) + 1; - LPWSTR p = HeapAlloc( heap, flags, len * sizeof(WCHAR) ); - if(p) { - SET_EIP(p); - strcpyW( p, str ); - } - return p; -} - - -/*********************************************************************** - * HEAP_strdupAtoW - */ -LPWSTR HEAP_strdupAtoW( HANDLE heap, DWORD flags, LPCSTR str ) -{ - LPWSTR ret; - INT len; - - if (!str) return NULL; - len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 ); - ret = HeapAlloc( heap, flags, len * sizeof(WCHAR) ); - if (ret) { - SET_EIP(ret); - MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len ); - } - return ret; -} - - -/*********************************************************************** - * HEAP_strdupWtoA - */ -LPSTR HEAP_strdupWtoA( HANDLE heap, DWORD flags, LPCWSTR str ) -{ - LPSTR ret; - INT len; - - if (!str) return NULL; - len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL ); - ret = HeapAlloc( heap, flags, len ); - if(ret) { - SET_EIP(ret); - WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL ); - } - return ret; -} - - - -/*********************************************************************** * 32-bit local heap functions (Win95; undocumented) */ -- 2.11.4.GIT