Nikolay Sivov : dwrite: Use helpers to search through loaders lists.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Oct 24 08:32:35 CDT 2014
Module: wine
Branch: master
Commit: 2300602586b8e1ff75a0c6d7773955b668437c8c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2300602586b8e1ff75a0c6d7773955b668437c8c
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Fri Oct 24 11:41:46 2014 +0400
dwrite: Use helpers to search through loaders lists.
---
dlls/dwrite/main.c | 36 ++++++++++++++++++++----------------
1 file changed, 20 insertions(+), 16 deletions(-)
diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c
index 57e0038..4c549d6 100644
--- a/dlls/dwrite/main.c
+++ b/dlls/dwrite/main.c
@@ -495,6 +495,20 @@ static struct fileloader *factory_get_file_loader(struct dwritefactory *factory,
return found;
}
+static struct collectionloader *factory_get_collection_loader(struct dwritefactory *factory, IDWriteFontCollectionLoader *loader)
+{
+ struct collectionloader *entry, *found = NULL;
+
+ LIST_FOR_EACH_ENTRY(entry, &factory->collection_loaders, struct collectionloader, entry) {
+ if (entry->loader == loader) {
+ found = entry;
+ break;
+ }
+ }
+
+ return found;
+}
+
static HRESULT WINAPI dwritefactory_QueryInterface(IDWriteFactory *iface, REFIID riid, void **obj)
{
struct dwritefactory *This = impl_from_IDWriteFactory(iface);
@@ -575,10 +589,8 @@ static HRESULT WINAPI dwritefactory_RegisterFontCollectionLoader(IDWriteFactory
if (!loader)
return E_INVALIDARG;
- LIST_FOR_EACH_ENTRY(entry, &This->collection_loaders, struct collectionloader, entry) {
- if (entry->loader == loader)
- return DWRITE_E_ALREADYREGISTERED;
- }
+ if (factory_get_collection_loader(This, loader))
+ return DWRITE_E_ALREADYREGISTERED;
entry = heap_alloc(sizeof(*entry));
if (!entry)
@@ -595,20 +607,14 @@ static HRESULT WINAPI dwritefactory_UnregisterFontCollectionLoader(IDWriteFactor
IDWriteFontCollectionLoader *loader)
{
struct dwritefactory *This = impl_from_IDWriteFactory(iface);
- struct collectionloader *entry, *found = NULL;
+ struct collectionloader *found;
TRACE("(%p)->(%p)\n", This, loader);
if (!loader)
return E_INVALIDARG;
- LIST_FOR_EACH_ENTRY(entry, &This->collection_loaders, struct collectionloader, entry) {
- if (entry->loader == loader) {
- found = entry;
- break;
- }
- }
-
+ found = factory_get_collection_loader(This, loader);
if (!found)
return E_INVALIDARG;
@@ -784,10 +790,8 @@ static HRESULT WINAPI dwritefactory_RegisterFontFileLoader(IDWriteFactory *iface
if (!loader)
return E_INVALIDARG;
- LIST_FOR_EACH_ENTRY(entry, &This->file_loaders, struct fileloader, entry) {
- if (entry->loader == loader)
- return DWRITE_E_ALREADYREGISTERED;
- }
+ if (factory_get_file_loader(This, loader))
+ return DWRITE_E_ALREADYREGISTERED;
entry = heap_alloc(sizeof(*entry));
if (!entry)
More information about the wine-cvs
mailing list