include: Get rid of heap.h.

This commit is contained in:
Alexandre Julliard 2006-11-17 15:29:40 +01:00
parent 75b8f88875
commit 2731998ae6
4 changed files with 50 additions and 66 deletions

View File

@ -28,7 +28,6 @@
#include "psdrv.h" #include "psdrv.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "winspool.h" #include "winspool.h"
#include "heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(psdrv); WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
@ -434,22 +433,38 @@ INT PSDRV_StartDocA( PSDRV_PDEVICE *physDev, const DOCINFOA *doc )
INT PSDRV_StartDoc( PSDRV_PDEVICE *physDev, const DOCINFOW *doc ) INT PSDRV_StartDoc( PSDRV_PDEVICE *physDev, const DOCINFOW *doc )
{ {
DOCINFOA docA; DOCINFOA docA;
INT ret; INT ret, len;
LPSTR docname = NULL, output = NULL, datatype = NULL;
docA.cbSize = doc->cbSize; docA.cbSize = doc->cbSize;
docA.lpszDocName = doc->lpszDocName ? if (doc->lpszDocName)
HEAP_strdupWtoA( GetProcessHeap(), 0, doc->lpszDocName ) : NULL; {
docA.lpszOutput = doc->lpszOutput ? len = WideCharToMultiByte( CP_ACP, 0, doc->lpszDocName, -1, NULL, 0, NULL, NULL );
HEAP_strdupWtoA( GetProcessHeap(), 0, doc->lpszOutput ) : NULL; if ((docname = HeapAlloc( GetProcessHeap(), 0, len )))
docA.lpszDatatype = doc->lpszDatatype ? WideCharToMultiByte( CP_ACP, 0, doc->lpszDocName, -1, docname, len, NULL, NULL );
HEAP_strdupWtoA( GetProcessHeap(), 0, doc->lpszDatatype ) : NULL; }
if (doc->lpszOutput)
{
len = WideCharToMultiByte( CP_ACP, 0, doc->lpszOutput, -1, NULL, 0, NULL, NULL );
if ((output = HeapAlloc( GetProcessHeap(), 0, len )))
WideCharToMultiByte( CP_ACP, 0, doc->lpszOutput, -1, output, len, NULL, NULL );
}
if (doc->lpszDatatype)
{
len = WideCharToMultiByte( CP_ACP, 0, doc->lpszDatatype, -1, NULL, 0, NULL, NULL );
if ((datatype = HeapAlloc( GetProcessHeap(), 0, len )))
WideCharToMultiByte( CP_ACP, 0, doc->lpszDatatype, -1, datatype, len, NULL, NULL );
}
docA.lpszDocName = docname;
docA.lpszOutput = output;
docA.lpszDatatype = datatype;
docA.fwType = doc->fwType; docA.fwType = doc->fwType;
ret = PSDRV_StartDocA(physDev, &docA); ret = PSDRV_StartDocA(physDev, &docA);
HeapFree( GetProcessHeap(), 0, (LPSTR)docA.lpszDocName ); HeapFree( GetProcessHeap(), 0, docname );
HeapFree( GetProcessHeap(), 0, (LPSTR)docA.lpszOutput ); HeapFree( GetProcessHeap(), 0, output );
HeapFree( GetProcessHeap(), 0, (LPSTR)docA.lpszDatatype ); HeapFree( GetProcessHeap(), 0, datatype );
return ret; return ret;
} }

View File

@ -22,6 +22,7 @@
#include "config.h" #include "config.h"
#include "wine/port.h" #include "wine/port.h"
#include <stdarg.h>
#include <string.h> #include <string.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
# include <unistd.h> # include <unistd.h>
@ -33,13 +34,14 @@
#define NONAMELESSUNION #define NONAMELESSUNION
#define NONAMELESSSTRUCT #define NONAMELESSSTRUCT
#include "wine/debug.h" #include "windef.h"
#include "winbase.h"
#include "winerror.h" #include "winerror.h"
#include "wownt32.h" #include "wownt32.h"
#include "heap.h"
#include "winreg.h" #include "winreg.h"
#include "psdrv.h" #include "psdrv.h"
#include "winspool.h" #include "winspool.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(psdrv); WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
@ -353,7 +355,9 @@ BOOL PSDRV_CreateDC( HDC hdc, PSDRV_PDEVICE **pdev, LPCWSTR driver, LPCWSTR devi
physDev->logPixelsY = physDev->pi->ppd->DefaultResolution; physDev->logPixelsY = physDev->pi->ppd->DefaultResolution;
if (output) { if (output) {
physDev->job.output = HEAP_strdupWtoA( PSDRV_Heap, 0, output ); INT len = WideCharToMultiByte( CP_ACP, 0, output, -1, NULL, 0, NULL, NULL );
if ((physDev->job.output = HeapAlloc( PSDRV_Heap, 0, len )))
WideCharToMultiByte( CP_ACP, 0, output, -1, physDev->job.output, len, NULL, NULL );
} else } else
physDev->job.output = NULL; physDev->job.output = NULL;
physDev->job.hJob = 0; physDev->job.hJob = 0;

View File

@ -58,7 +58,6 @@
#include "wine/unicode.h" #include "wine/unicode.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/list.h" #include "wine/list.h"
#include "heap.h"
#include "winnls.h" #include "winnls.h"
#include "ddk/winsplp.h" #include "ddk/winsplp.h"
@ -332,6 +331,18 @@ static LPWSTR strdupW(LPCWSTR p)
return ret; return ret;
} }
static LPSTR strdupWtoA( LPCWSTR str )
{
LPSTR ret;
INT len;
if (!str) return NULL;
len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
ret = HeapAlloc( GetProcessHeap(), 0, len );
if(ret) WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
return ret;
}
/* Returns the number of bytes in an ansi \0\0 terminated string (multi_sz). /* Returns the number of bytes in an ansi \0\0 terminated string (multi_sz).
The result includes all \0s (specifically the last two). */ The result includes all \0s (specifically the last two). */
static int multi_sz_lenA(const char *str) static int multi_sz_lenA(const char *str)
@ -1589,8 +1600,8 @@ INT WINAPI DeviceCapabilitiesW(LPCWSTR pDevice, LPCWSTR pPort,
const DEVMODEW *pDevMode) const DEVMODEW *pDevMode)
{ {
LPDEVMODEA dmA = DEVMODEdupWtoA(GetProcessHeap(), pDevMode); LPDEVMODEA dmA = DEVMODEdupWtoA(GetProcessHeap(), pDevMode);
LPSTR pDeviceA = HEAP_strdupWtoA(GetProcessHeap(),0,pDevice); LPSTR pDeviceA = strdupWtoA(pDevice);
LPSTR pPortA = HEAP_strdupWtoA(GetProcessHeap(),0,pPort); LPSTR pPortA = strdupWtoA(pPort);
INT ret; INT ret;
if(pOutput && (fwCapability == DC_BINNAMES || if(pOutput && (fwCapability == DC_BINNAMES ||
@ -1653,7 +1664,7 @@ LONG WINAPI DocumentPropertiesA(HWND hWnd,HANDLE hPrinter,
SetLastError(ERROR_INVALID_HANDLE); SetLastError(ERROR_INVALID_HANDLE);
return -1; return -1;
} }
lpName = HEAP_strdupWtoA(GetProcessHeap(),0,lpNameW); lpName = strdupWtoA(lpNameW);
} }
if (!GDI_CallExtDeviceMode16) if (!GDI_CallExtDeviceMode16)
@ -1685,7 +1696,7 @@ LONG WINAPI DocumentPropertiesW(HWND hWnd, HANDLE hPrinter,
LPDEVMODEW pDevModeInput, DWORD fMode) LPDEVMODEW pDevModeInput, DWORD fMode)
{ {
LPSTR pDeviceNameA = HEAP_strdupWtoA(GetProcessHeap(),0,pDeviceName); LPSTR pDeviceNameA = strdupWtoA(pDeviceName);
LPDEVMODEA pDevModeInputA = DEVMODEdupWtoA(GetProcessHeap(),pDevModeInput); LPDEVMODEA pDevModeInputA = DEVMODEdupWtoA(GetProcessHeap(),pDevModeInput);
LPDEVMODEA pDevModeOutputA = NULL; LPDEVMODEA pDevModeOutputA = NULL;
LONG ret; LONG ret;
@ -3228,7 +3239,7 @@ static BOOL WINSPOOL_GetStringFromReg(HKEY hkey, LPCWSTR ValueName, LPBYTE ptr,
if(unicode) if(unicode)
ret = RegQueryValueExW(hkey, ValueName, 0, &type, ptr, &sz); ret = RegQueryValueExW(hkey, ValueName, 0, &type, ptr, &sz);
else { else {
LPSTR ValueNameA = HEAP_strdupWtoA(GetProcessHeap(),0,ValueName); LPSTR ValueNameA = strdupWtoA(ValueName);
ret = RegQueryValueExA(hkey, ValueNameA, 0, &type, ptr, &sz); ret = RegQueryValueExA(hkey, ValueNameA, 0, &type, ptr, &sz);
HeapFree(GetProcessHeap(),0,ValueNameA); HeapFree(GetProcessHeap(),0,ValueNameA);
} }

View File

@ -1,46 +0,0 @@
/*
* Win32 heap definitions
*
* Copyright 1996 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_HEAP_H
#define __WINE_HEAP_H
#include <stdarg.h>
#include <string.h>
#include <windef.h>
#include <winbase.h>
#include <winnls.h>
/* strdup macros */
/* DO NOT USE IT!! it will go away soon */
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;
}
#endif /* __WINE_HEAP_H */