Huw Davies : wineps: Change the printer info list into a standard list.
Alexandre Julliard
julliard at winehq.org
Wed Apr 4 13:07:06 CDT 2012
Module: wine
Branch: master
Commit: a2e6c7340d6059d394dcbeff3859384054a3513f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a2e6c7340d6059d394dcbeff3859384054a3513f
Author: Huw Davies <huw at codeweavers.com>
Date: Wed Apr 4 15:03:31 2012 +0100
wineps: Change the printer info list into a standard list.
---
dlls/wineps.drv/init.c | 24 ++++++++++--------------
dlls/wineps.drv/psdrv.h | 5 +++--
2 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c
index 84e4086..7e4ca51 100644
--- a/dlls/wineps.drv/init.c
+++ b/dlls/wineps.drv/init.c
@@ -530,15 +530,15 @@ static INT PSDRV_GetDeviceCaps( PHYSDEV dev, INT cap )
}
}
+static struct list printer_list = LIST_INIT( printer_list );
/**********************************************************************
* PSDRV_FindPrinterInfo
*/
PRINTERINFO *PSDRV_FindPrinterInfo(LPCWSTR name)
{
- static PRINTERINFO *PSDRV_PrinterList;
DWORD type = REG_BINARY, needed, res, dwPaperSize;
- PRINTERINFO *pi = PSDRV_PrinterList, **last = &PSDRV_PrinterList;
+ PRINTERINFO *pi;
FONTNAME *font;
const AFM *afm;
HANDLE hPrinter = 0;
@@ -551,17 +551,14 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCWSTR name)
TRACE("'%s'\n", debugstr_w(name));
- /*
- * If this loop completes, last will point to the 'next' element of the
- * final PRINTERINFO in the list
- */
- for( ; pi; last = &pi->next, pi = pi->next)
- if(!strcmpW(pi->friendly_name, name))
- return pi;
+ LIST_FOR_EACH_ENTRY( pi, &printer_list, PRINTERINFO, entry )
+ {
+ if (!strcmpW( pi->friendly_name, name ))
+ return pi;
+ }
- pi = *last = HeapAlloc( PSDRV_Heap, HEAP_ZERO_MEMORY, sizeof(*pi) );
- if (pi == NULL)
- return NULL;
+ pi = HeapAlloc( PSDRV_Heap, HEAP_ZERO_MEMORY, sizeof(*pi) );
+ if (pi == NULL) return NULL;
if (!(pi->friendly_name = HeapAlloc( PSDRV_Heap, 0, (strlenW(name)+1)*sizeof(WCHAR) ))) goto fail;
strcpyW( pi->friendly_name, name );
@@ -775,7 +772,6 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCWSTR name)
goto cleanup;
}
- pi->next = NULL;
pi->Fonts = NULL;
for(font = pi->ppd->InstalledFonts; font; font = font->next) {
@@ -795,6 +791,7 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCWSTR name)
}
HeapFree( GetProcessHeap(), 0, nameA );
if (ppd) unlink(ppd);
+ list_add_head( &printer_list, &pi->entry );
return pi;
closeprinter:
@@ -808,7 +805,6 @@ fail:
HeapFree(PSDRV_Heap, 0, pi);
HeapFree( GetProcessHeap(), 0, nameA );
if (ppd) unlink(ppd);
- *last = NULL;
return NULL;
}
diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h
index 53186c7..df86c70 100644
--- a/dlls/wineps.drv/psdrv.h
+++ b/dlls/wineps.drv/psdrv.h
@@ -241,14 +241,15 @@ numInstalledOptions of OPTIONs
} PSDRV_DEVMODEA;
-typedef struct _tagPI {
+typedef struct
+{
+ struct list entry;
WCHAR *friendly_name;
PPD *ppd;
PSDRV_DEVMODEA *Devmode;
FONTFAMILY *Fonts;
PPRINTER_ENUM_VALUESA FontSubTable;
DWORD FontSubTableSize;
- struct _tagPI *next;
} PRINTERINFO;
typedef struct {
More information about the wine-cvs
mailing list