Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/scrrun/dictionary.c | 71 ++++++++++--------- dlls/scrrun/filesystem.c | 143 ++++++++++++++++++++------------------- 2 files changed, 107 insertions(+), 107 deletions(-)
diff --git a/dlls/scrrun/dictionary.c b/dlls/scrrun/dictionary.c index 477943f6579..b946d8ad25b 100644 --- a/dlls/scrrun/dictionary.c +++ b/dlls/scrrun/dictionary.c @@ -30,7 +30,6 @@ #include "scrrun_private.h"
#include "wine/debug.h" -#include "wine/heap.h" #include "wine/list.h"
WINE_DEFAULT_DEBUG_CHANNEL(scrrun); @@ -177,8 +176,7 @@ static HRESULT add_keyitem_pair(dictionary *dict, VARIANT *key, VARIANT *item) if (FAILED(hr)) return hr;
- pair = heap_alloc(sizeof(*pair)); - if (!pair) + if (!(pair = malloc(sizeof(*pair)))) return E_OUTOFMEMORY;
pair->hash = V_I4(&hash); @@ -207,7 +205,7 @@ static HRESULT add_keyitem_pair(dictionary *dict, VARIANT *key, VARIANT *item) failed: VariantClear(&pair->key); VariantClear(&pair->item); - heap_free(pair); + free(pair); return hr; }
@@ -215,7 +213,7 @@ static void free_keyitem_pair(struct keyitem_pair *pair) { VariantClear(&pair->key); VariantClear(&pair->item); - heap_free(pair); + free(pair); }
static HRESULT WINAPI dict_enum_QueryInterface(IEnumVARIANT *iface, REFIID riid, void **obj) @@ -251,10 +249,11 @@ static ULONG WINAPI dict_enum_Release(IEnumVARIANT *iface)
TRACE("(%p)->(%u)\n", This, ref);
- if (!ref) { + if (!ref) + { list_remove(&This->notify); IDictionary_Release(&This->dict->IDictionary_iface); - heap_free(This); + free(This); }
return ref; @@ -338,22 +337,22 @@ static const IEnumVARIANTVtbl dictenumvtbl = {
static HRESULT create_dict_enum(dictionary *dict, IUnknown **ret) { - struct dictionary_enum *This; + struct dictionary_enum *object;
*ret = NULL;
- This = heap_alloc(sizeof(*This)); - if (!This) + if (!(object = calloc(1, sizeof(*object)))) return E_OUTOFMEMORY;
- This->IEnumVARIANT_iface.lpVtbl = &dictenumvtbl; - This->ref = 1; - This->cur = list_head(&dict->pairs); - list_add_tail(&dict->notifier, &This->notify); - This->dict = dict; + object->IEnumVARIANT_iface.lpVtbl = &dictenumvtbl; + object->ref = 1; + object->cur = list_head(&dict->pairs); + list_add_tail(&dict->notifier, &object->notify); + object->dict = dict; IDictionary_AddRef(&dict->IDictionary_iface);
- *ret = (IUnknown*)&This->IEnumVARIANT_iface; + *ret = (IUnknown *)&object->IEnumVARIANT_iface; + return S_OK; }
@@ -423,14 +422,15 @@ static ULONG WINAPI dictionary_AddRef(IDictionary *iface)
static ULONG WINAPI dictionary_Release(IDictionary *iface) { - dictionary *This = impl_from_IDictionary(iface); - ULONG ref = InterlockedDecrement(&This->ref); + dictionary *dictionary = impl_from_IDictionary(iface); + ULONG ref = InterlockedDecrement(&dictionary->ref);
- TRACE("(%p)->(%u)\n", This, ref); + TRACE("%p, refcount %u.\n", iface, ref);
- if (!ref) { + if (!ref) + { IDictionary_RemoveAll(iface); - heap_free(This); + free(dictionary); }
return ref; @@ -885,27 +885,26 @@ static const struct IDictionaryVtbl dictionary_vtbl = dictionary_get_HashVal };
-HRESULT WINAPI Dictionary_CreateInstance(IClassFactory *factory,IUnknown *outer,REFIID riid, void **obj) +HRESULT WINAPI Dictionary_CreateInstance(IClassFactory *factory, IUnknown *outer, REFIID riid, void **ret) { - dictionary *This; + dictionary *object;
- TRACE("(%p, %p, %s, %p)\n", factory, outer, debugstr_guid(riid), obj); + TRACE("(%p, %p, %s, %p)\n", factory, outer, debugstr_guid(riid), ret);
- *obj = NULL; + *ret = NULL;
- This = heap_alloc(sizeof(*This)); - if(!This) return E_OUTOFMEMORY; + if (!(object = calloc(1, sizeof(*object)))) + return E_OUTOFMEMORY;
- This->IDictionary_iface.lpVtbl = &dictionary_vtbl; - This->ref = 1; - This->method = BinaryCompare; - This->count = 0; - list_init(&This->pairs); - list_init(&This->notifier); - memset(This->buckets, 0, sizeof(This->buckets)); + object->IDictionary_iface.lpVtbl = &dictionary_vtbl; + object->ref = 1; + object->method = BinaryCompare; + list_init(&object->pairs); + list_init(&object->notifier); + + init_classinfo(&CLSID_Dictionary, (IUnknown *)&object->IDictionary_iface, &object->classinfo);
- init_classinfo(&CLSID_Dictionary, (IUnknown *)&This->IDictionary_iface, &This->classinfo); - *obj = &This->IDictionary_iface; + *ret = &object->IDictionary_iface;
return S_OK; } diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c index 5d7d42850ab..e525b9db8da 100644 --- a/dlls/scrrun/filesystem.c +++ b/dlls/scrrun/filesystem.c @@ -33,7 +33,6 @@ #include "scrrun_private.h"
#include "wine/debug.h" -#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(scrrun);
@@ -317,15 +316,16 @@ static ULONG WINAPI textstream_AddRef(ITextStream *iface)
static ULONG WINAPI textstream_Release(ITextStream *iface) { - struct textstream *This = impl_from_ITextStream(iface); - ULONG ref = InterlockedDecrement(&This->ref); - TRACE("(%p)->(%d)\n", This, ref); + struct textstream *stream = impl_from_ITextStream(iface); + ULONG ref = InterlockedDecrement(&stream->ref); + + TRACE("%p, refcount %d.\n", iface, ref);
if (!ref) { - if (This->read_buf_size) heap_free(This->read_buf); - CloseHandle(This->file); - heap_free(This); + if (stream->read_buf_size) free(stream->read_buf); + CloseHandle(stream->file); + free(stream); }
return ref; @@ -462,9 +462,9 @@ static HRESULT append_read_data(struct textstream *stream, const char *buf, size SetFilePointerEx(stream->file, revert, NULL, FILE_CURRENT);
if (!stream->read_buf_size) - new_buf = heap_alloc(len * sizeof(WCHAR)); + new_buf = malloc(len * sizeof(WCHAR)); else - new_buf = heap_realloc(stream->read_buf, (len + stream->read_buf_size) * sizeof(WCHAR)); + new_buf = realloc(stream->read_buf, (len + stream->read_buf_size) * sizeof(WCHAR)); if (!new_buf) return E_OUTOFMEMORY;
if (stream->unicode) @@ -504,7 +504,7 @@ static BOOL read_from_buffer(struct textstream *stream, size_t len, BSTR *ret, s if (stream->read_buf_size) memmove(stream->read_buf, stream->read_buf + len, stream->read_buf_size * sizeof(WCHAR)); else - heap_free(stream->read_buf); + free(stream->read_buf); return TRUE; }
@@ -622,14 +622,14 @@ static HRESULT textstream_writestr(struct textstream *stream, BSTR text) char *buffA; HRESULT hr;
- buffA = heap_alloc(len); + buffA = malloc(len); if (!buffA) return E_OUTOFMEMORY;
WideCharToMultiByte(CP_ACP, 0, text, SysStringLen(text), buffA, len, NULL, NULL); ret = WriteFile(stream->file, buffA, len, &written, NULL); hr = (ret && written == len) ? S_OK : create_error(GetLastError()); - heap_free(buffA); + free(buffA); return hr; } } @@ -765,21 +765,18 @@ static HRESULT create_textstream(const WCHAR *filename, DWORD disposition, IOMod return E_INVALIDARG; }
- stream = heap_alloc(sizeof(struct textstream)); - if (!stream) return E_OUTOFMEMORY; + if (!(stream = calloc(1, sizeof(*stream)))) + return E_OUTOFMEMORY;
stream->ITextStream_iface.lpVtbl = &textstreamvtbl; stream->ref = 1; stream->mode = mode; - stream->eof = FALSE; - stream->read_buf = NULL; - stream->read_buf_size = 0;
stream->file = CreateFileW(filename, access, 0, NULL, disposition, FILE_ATTRIBUTE_NORMAL, NULL); if (stream->file == INVALID_HANDLE_VALUE) { HRESULT hr = create_error(GetLastError()); - heap_free(stream); + free(stream); return hr; }
@@ -877,12 +874,13 @@ static ULONG WINAPI drive_AddRef(IDrive *iface)
static ULONG WINAPI drive_Release(IDrive *iface) { - struct drive *This = impl_from_IDrive(iface); - ULONG ref = InterlockedDecrement(&This->ref); - TRACE("(%p)->(%d)\n", This, ref); + struct drive *drive = impl_from_IDrive(iface); + ULONG ref = InterlockedDecrement(&drive->ref); + + TRACE("%p, refcount %d.\n", iface, ref);
if (!ref) - heap_free(This); + free(drive);
return ref; } @@ -1182,7 +1180,7 @@ static HRESULT create_drive(WCHAR letter, IDrive **drive)
*drive = NULL;
- object = heap_alloc(sizeof(*object)); + object = malloc(sizeof(*object)); if (!object) return E_OUTOFMEMORY;
object->IDrive_iface.lpVtbl = &drivevtbl; @@ -1235,7 +1233,7 @@ static ULONG WINAPI foldercoll_enumvariant_Release(IEnumVARIANT *iface) { IFolderCollection_Release(&This->data.u.foldercoll.coll->IFolderCollection_iface); FindClose(This->data.u.foldercoll.find); - heap_free(This); + free(This); }
return ref; @@ -1392,7 +1390,7 @@ static HRESULT create_foldercoll_enum(struct foldercollection *collection, IUnkn
*newenum = NULL;
- This = heap_alloc(sizeof(*This)); + This = malloc(sizeof(*This)); if (!This) return E_OUTOFMEMORY;
This->IEnumVARIANT_iface.lpVtbl = &foldercollenumvariantvtbl; @@ -1417,7 +1415,7 @@ static ULONG WINAPI filecoll_enumvariant_Release(IEnumVARIANT *iface) { IFileCollection_Release(&This->data.u.filecoll.coll->IFileCollection_iface); FindClose(This->data.u.filecoll.find); - heap_free(This); + free(This); }
return ref; @@ -1534,7 +1532,7 @@ static HRESULT create_filecoll_enum(struct filecollection *collection, IUnknown
*newenum = NULL;
- This = heap_alloc(sizeof(*This)); + This = malloc(sizeof(*This)); if (!This) return E_OUTOFMEMORY;
This->IEnumVARIANT_iface.lpVtbl = &filecollenumvariantvtbl; @@ -1558,7 +1556,7 @@ static ULONG WINAPI drivecoll_enumvariant_Release(IEnumVARIANT *iface) if (!ref) { IDriveCollection_Release(&This->data.u.drivecoll.coll->IDriveCollection_iface); - heap_free(This); + free(This); }
return ref; @@ -1657,7 +1655,7 @@ static HRESULT create_drivecoll_enum(struct drivecollection *collection, IUnknow
*newenum = NULL;
- This = heap_alloc(sizeof(*This)); + This = malloc(sizeof(*This)); if (!This) return E_OUTOFMEMORY;
This->IEnumVARIANT_iface.lpVtbl = &drivecollenumvariantvtbl; @@ -1713,7 +1711,7 @@ static ULONG WINAPI foldercoll_Release(IFolderCollection *iface) if (!ref) { SysFreeString(This->path); - heap_free(This); + free(This); }
return ref; @@ -1854,7 +1852,7 @@ static HRESULT create_foldercoll(BSTR path, IFolderCollection **folders)
*folders = NULL;
- This = heap_alloc(sizeof(struct foldercollection)); + This = malloc(sizeof(*This)); if (!This) return E_OUTOFMEMORY;
This->IFolderCollection_iface.lpVtbl = &foldercollvtbl; @@ -1862,7 +1860,7 @@ static HRESULT create_foldercoll(BSTR path, IFolderCollection **folders) This->path = SysAllocString(path); if (!This->path) { - heap_free(This); + free(This); return E_OUTOFMEMORY; }
@@ -1914,7 +1912,7 @@ static ULONG WINAPI filecoll_Release(IFileCollection *iface) if (!ref) { SysFreeString(This->path); - heap_free(This); + free(This); }
return ref; @@ -2047,7 +2045,7 @@ static HRESULT create_filecoll(BSTR path, IFileCollection **files)
*files = NULL;
- This = heap_alloc(sizeof(*This)); + This = malloc(sizeof(*This)); if (!This) return E_OUTOFMEMORY;
This->IFileCollection_iface.lpVtbl = &filecollectionvtbl; @@ -2055,7 +2053,7 @@ static HRESULT create_filecoll(BSTR path, IFileCollection **files) This->path = SysAllocString(path); if (!This->path) { - heap_free(This); + free(This); return E_OUTOFMEMORY; }
@@ -2104,7 +2102,7 @@ static ULONG WINAPI drivecoll_Release(IDriveCollection *iface) TRACE("(%p)->(%d)\n", This, ref);
if (!ref) - heap_free(This); + free(This);
return ref; } @@ -2219,7 +2217,7 @@ static HRESULT create_drivecoll(IDriveCollection **drives)
*drives = NULL;
- This = heap_alloc(sizeof(*This)); + This = malloc(sizeof(*This)); if (!This) return E_OUTOFMEMORY;
This->IDriveCollection_iface.lpVtbl = &drivecollectionvtbl; @@ -2276,7 +2274,7 @@ static ULONG WINAPI folder_Release(IFolder *iface) if (!ref) { SysFreeString(This->path); - heap_free(This); + free(This); }
return ref; @@ -2568,26 +2566,26 @@ static const IFolderVtbl foldervtbl = {
HRESULT create_folder(const WCHAR *path, IFolder **folder) { - struct folder *This; + struct folder *object;
*folder = NULL;
TRACE("%s\n", debugstr_w(path));
- This = heap_alloc(sizeof(struct folder)); - if (!This) return E_OUTOFMEMORY; + if (!(object = malloc(sizeof(*object)))) + return E_OUTOFMEMORY;
- This->IFolder_iface.lpVtbl = &foldervtbl; - This->ref = 1; - This->path = SysAllocString(path); - if (!This->path) + object->IFolder_iface.lpVtbl = &foldervtbl; + object->ref = 1; + object->path = SysAllocString(path); + if (!object->path) { - heap_free(This); + free(object); return E_OUTOFMEMORY; }
- init_classinfo(&CLSID_Folder, (IUnknown *)&This->IFolder_iface, &This->classinfo); - *folder = &This->IFolder_iface; + init_classinfo(&CLSID_Folder, (IUnknown *)&object->IFolder_iface, &object->classinfo); + *folder = &object->IFolder_iface;
return S_OK; } @@ -2629,15 +2627,15 @@ static ULONG WINAPI file_AddRef(IFile *iface)
static ULONG WINAPI file_Release(IFile *iface) { - struct file *This = impl_from_IFile(iface); - LONG ref = InterlockedDecrement(&This->ref); + struct file *file = impl_from_IFile(iface); + LONG ref = InterlockedDecrement(&file->ref);
- TRACE("(%p) ref=%d\n", This, ref); + TRACE("%p, refcount %d.\n", iface, ref);
- if(!ref) + if (!ref) { - heap_free(This->path); - heap_free(This); + free(file->path); + free(file); }
return ref; @@ -2942,7 +2940,7 @@ static HRESULT create_file(BSTR path, IFile **file)
*file = NULL;
- f = heap_alloc(sizeof(struct file)); + f = malloc(sizeof(struct file)); if(!f) return E_OUTOFMEMORY;
@@ -2950,28 +2948,31 @@ static HRESULT create_file(BSTR path, IFile **file) f->ref = 1;
len = GetFullPathNameW(path, 0, NULL, NULL); - if(!len) { - heap_free(f); + if (!len) + { + free(f); return E_FAIL; }
- f->path = heap_alloc(len*sizeof(WCHAR)); - if(!f->path) { - heap_free(f); + f->path = malloc(len*sizeof(WCHAR)); + if(!f->path) + { + free(f); return E_OUTOFMEMORY; }
- if(!GetFullPathNameW(path, len, f->path, NULL)) { - heap_free(f->path); - heap_free(f); + if (!GetFullPathNameW(path, len, f->path, NULL)) + { + free(f->path); + free(f); return E_FAIL; }
attrs = GetFileAttributesW(f->path); - if(attrs==INVALID_FILE_ATTRIBUTES || - (attrs&(FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_DEVICE))) { - heap_free(f->path); - heap_free(f); + if (attrs == INVALID_FILE_ATTRIBUTES || (attrs & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE))) + { + free(f->path); + free(f); return create_error(GetLastError()); }
@@ -3931,22 +3932,22 @@ static HRESULT WINAPI filesys_GetFileVersion(IFileSystem3 *iface, BSTR name, BST if (!len) return HRESULT_FROM_WIN32(GetLastError());
- ptr = heap_alloc(len); + ptr = malloc(len); if (!GetFileVersionInfoW(name, 0, len, ptr)) { - heap_free(ptr); + free(ptr); return HRESULT_FROM_WIN32(GetLastError()); }
ret = VerQueryValueW(ptr, L"\", (void **)&info, &len); if (!ret) { - heap_free(ptr); + free(ptr); return HRESULT_FROM_WIN32(GetLastError()); }
get_versionstring(info, ver); - heap_free(ptr); + free(ptr);
*version = SysAllocString(ver); TRACE("version=%s\n", debugstr_w(ver));
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/scrrun/dictionary.c | 175 ++++++++++++++++++++------------------- 1 file changed, 88 insertions(+), 87 deletions(-)
diff --git a/dlls/scrrun/dictionary.c b/dlls/scrrun/dictionary.c index b946d8ad25b..d1c6eb24e0b 100644 --- a/dlls/scrrun/dictionary.c +++ b/dlls/scrrun/dictionary.c @@ -52,7 +52,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(scrrun); indicates that pairs are not reordered basing on hash value. */
-struct keyitem_pair { +struct keyitem_pair +{ struct list entry; struct list bucket; DWORD hash; @@ -60,7 +61,7 @@ struct keyitem_pair { VARIANT item; };
-typedef struct +struct dictionary { struct provideclassinfo classinfo; IDictionary IDictionary_iface; @@ -71,20 +72,21 @@ typedef struct struct list pairs; struct list buckets[BUCKET_COUNT]; struct list notifier; -} dictionary; +};
-struct dictionary_enum { +struct dictionary_enum +{ IEnumVARIANT IEnumVARIANT_iface; LONG ref;
- dictionary *dict; + struct dictionary *dict; struct list *cur; struct list notify; };
-static inline dictionary *impl_from_IDictionary(IDictionary *iface) +static inline struct dictionary *impl_from_IDictionary(IDictionary *iface) { - return CONTAINING_RECORD(iface, dictionary, IDictionary_iface); + return CONTAINING_RECORD(iface, struct dictionary, IDictionary_iface); }
static inline struct dictionary_enum *impl_from_IEnumVARIANT(IEnumVARIANT *iface) @@ -92,7 +94,7 @@ static inline struct dictionary_enum *impl_from_IEnumVARIANT(IEnumVARIANT *iface return CONTAINING_RECORD(iface, struct dictionary_enum, IEnumVARIANT_iface); }
-static inline struct list *get_bucket_head(dictionary *dict, DWORD hash) +static inline struct list *get_bucket_head(struct dictionary *dict, DWORD hash) { return &dict->buckets[hash % BUCKET_COUNT]; } @@ -115,7 +117,7 @@ static inline WCHAR *get_key_strptr(const VARIANT *key) }
/* should be used only when both keys are of string type, it's not checked */ -static inline int strcmp_key(const dictionary *dict, const VARIANT *key1, const VARIANT *key2) +static inline int strcmp_key(const struct dictionary *dict, const VARIANT *key1, const VARIANT *key2) { const WCHAR *str1, *str2;
@@ -124,7 +126,7 @@ static inline int strcmp_key(const dictionary *dict, const VARIANT *key1, const return dict->method == BinaryCompare ? wcscmp(str1, str2) : wcsicmp(str1, str2); }
-static BOOL is_matching_key(const dictionary *dict, const struct keyitem_pair *pair, const VARIANT *key, DWORD hash) +static BOOL is_matching_key(const struct dictionary *dict, const struct keyitem_pair *pair, const VARIANT *key, DWORD hash) { if (is_string_key(key) && is_string_key(&pair->key)) { if (hash != pair->hash) @@ -141,7 +143,7 @@ static BOOL is_matching_key(const dictionary *dict, const struct keyitem_pair *p return hash == pair->hash; }
-static struct keyitem_pair *get_keyitem_pair(dictionary *dict, VARIANT *key) +static struct keyitem_pair *get_keyitem_pair(struct dictionary *dict, VARIANT *key) { struct keyitem_pair *pair; struct list *head, *entry; @@ -165,7 +167,7 @@ static struct keyitem_pair *get_keyitem_pair(dictionary *dict, VARIANT *key) return NULL; }
-static HRESULT add_keyitem_pair(dictionary *dict, VARIANT *key, VARIANT *item) +static HRESULT add_keyitem_pair(struct dictionary *dict, VARIANT *key, VARIANT *item) { struct keyitem_pair *pair; struct list *head; @@ -316,7 +318,7 @@ static HRESULT WINAPI dict_enum_Reset(IEnumVARIANT *iface) return S_OK; }
-static HRESULT create_dict_enum(dictionary*, IUnknown**); +static HRESULT create_dict_enum(struct dictionary *, IUnknown**);
static HRESULT WINAPI dict_enum_Clone(IEnumVARIANT *iface, IEnumVARIANT **cloned) { @@ -335,7 +337,7 @@ static const IEnumVARIANTVtbl dictenumvtbl = { dict_enum_Clone };
-static HRESULT create_dict_enum(dictionary *dict, IUnknown **ret) +static HRESULT create_dict_enum(struct dictionary *dict, IUnknown **ret) { struct dictionary_enum *object;
@@ -373,8 +375,9 @@ static void notify_remove_pair(struct list *notifier, struct list *pair)
static HRESULT WINAPI dictionary_QueryInterface(IDictionary *iface, REFIID riid, void **obj) { - dictionary *This = impl_from_IDictionary(iface); - TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), obj); + struct dictionary *dictionary = impl_from_IDictionary(iface); + + TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
*obj = NULL;
@@ -382,11 +385,11 @@ static HRESULT WINAPI dictionary_QueryInterface(IDictionary *iface, REFIID riid, IsEqualIID(riid, &IID_IDispatch) || IsEqualIID(riid, &IID_IDictionary)) { - *obj = &This->IDictionary_iface; + *obj = &dictionary->IDictionary_iface; } else if (IsEqualIID(riid, &IID_IProvideClassInfo)) { - *obj = &This->classinfo.IProvideClassInfo_iface; + *obj = &dictionary->classinfo.IProvideClassInfo_iface; } else if ( IsEqualGUID( riid, &IID_IDispatchEx )) { @@ -412,17 +415,17 @@ static HRESULT WINAPI dictionary_QueryInterface(IDictionary *iface, REFIID riid,
static ULONG WINAPI dictionary_AddRef(IDictionary *iface) { - dictionary *This = impl_from_IDictionary(iface); - ULONG ref = InterlockedIncrement(&This->ref); + struct dictionary *dictionary = impl_from_IDictionary(iface); + ULONG ref = InterlockedIncrement(&dictionary->ref);
- TRACE("(%p)->(%u)\n", This, ref); + TRACE("%p, refcount %u.\n", iface, ref);
return ref; }
static ULONG WINAPI dictionary_Release(IDictionary *iface) { - dictionary *dictionary = impl_from_IDictionary(iface); + struct dictionary *dictionary = impl_from_IDictionary(iface); ULONG ref = InterlockedDecrement(&dictionary->ref);
TRACE("%p, refcount %u.\n", iface, ref); @@ -438,9 +441,7 @@ static ULONG WINAPI dictionary_Release(IDictionary *iface)
static HRESULT WINAPI dictionary_GetTypeInfoCount(IDictionary *iface, UINT *pctinfo) { - dictionary *This = impl_from_IDictionary(iface); - - TRACE("(%p)->(%p)\n", This, pctinfo); + TRACE("%p, %p.\n", iface, pctinfo);
*pctinfo = 1; return S_OK; @@ -448,20 +449,18 @@ static HRESULT WINAPI dictionary_GetTypeInfoCount(IDictionary *iface, UINT *pcti
static HRESULT WINAPI dictionary_GetTypeInfo(IDictionary *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) { - dictionary *This = impl_from_IDictionary(iface); + TRACE("%p, %u, %u, %p.\n", iface, iTInfo, lcid, ppTInfo);
- TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo); return get_typeinfo(IDictionary_tid, ppTInfo); }
static HRESULT WINAPI dictionary_GetIDsOfNames(IDictionary *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) { - dictionary *This = impl_from_IDictionary(iface); ITypeInfo *typeinfo; HRESULT hr;
- TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId); + TRACE("%p, %s, %p, %u, %u, %p.\n", iface, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
hr = get_typeinfo(IDictionary_tid, &typeinfo); if(SUCCEEDED(hr)) @@ -477,17 +476,17 @@ static HRESULT WINAPI dictionary_Invoke(IDictionary *iface, DISPID dispIdMember, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) { - dictionary *This = impl_from_IDictionary(iface); + struct dictionary *dictionary = impl_from_IDictionary(iface); ITypeInfo *typeinfo; HRESULT hr;
- TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid), + TRACE("%p, %d, %s, %d, %d, %p, %p, %p, %p.\n", iface, dispIdMember, debugstr_guid(riid), lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
hr = get_typeinfo(IDictionary_tid, &typeinfo); if(SUCCEEDED(hr)) { - hr = ITypeInfo_Invoke(typeinfo, &This->IDictionary_iface, dispIdMember, wFlags, + hr = ITypeInfo_Invoke(typeinfo, &dictionary->IDictionary_iface, dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); ITypeInfo_Release(typeinfo); } @@ -497,21 +496,19 @@ static HRESULT WINAPI dictionary_Invoke(IDictionary *iface, DISPID dispIdMember,
static HRESULT WINAPI dictionary_putref_Item(IDictionary *iface, VARIANT *Key, VARIANT *pRetItem) { - dictionary *This = impl_from_IDictionary(iface); - - FIXME("(%p)->(%p %p)\n", This, Key, pRetItem); + FIXME("%p, %p, %p stub\n", iface, Key, pRetItem);
return E_NOTIMPL; }
static HRESULT WINAPI dictionary_put_Item(IDictionary *iface, VARIANT *key, VARIANT *item) { - dictionary *This = impl_from_IDictionary(iface); + struct dictionary *dictionary = impl_from_IDictionary(iface); struct keyitem_pair *pair;
- TRACE("(%p)->(%s %s)\n", This, debugstr_variant(key), debugstr_variant(item)); + TRACE("%p, %s, %s.\n", iface, debugstr_variant(key), debugstr_variant(item));
- if ((pair = get_keyitem_pair(This, key))) + if ((pair = get_keyitem_pair(dictionary, key))) return VariantCopyInd(&pair->item, item);
return IDictionary_Add(iface, key, item); @@ -519,12 +516,12 @@ static HRESULT WINAPI dictionary_put_Item(IDictionary *iface, VARIANT *key, VARI
static HRESULT WINAPI dictionary_get_Item(IDictionary *iface, VARIANT *key, VARIANT *item) { - dictionary *This = impl_from_IDictionary(iface); + struct dictionary *dictionary = impl_from_IDictionary(iface); struct keyitem_pair *pair;
- TRACE("(%p)->(%s %p)\n", This, debugstr_variant(key), item); + TRACE("%p, %s, %p.\n", iface, debugstr_variant(key), item);
- if ((pair = get_keyitem_pair(This, key))) + if ((pair = get_keyitem_pair(dictionary, key))) VariantCopy(item, &pair->item); else { VariantInit(item); @@ -536,42 +533,42 @@ static HRESULT WINAPI dictionary_get_Item(IDictionary *iface, VARIANT *key, VARI
static HRESULT WINAPI dictionary_Add(IDictionary *iface, VARIANT *key, VARIANT *item) { - dictionary *This = impl_from_IDictionary(iface); + struct dictionary *dictionary = impl_from_IDictionary(iface);
- TRACE("(%p)->(%s %s)\n", This, debugstr_variant(key), debugstr_variant(item)); + TRACE("%p, %s, %s.\n", iface, debugstr_variant(key), debugstr_variant(item));
- if (get_keyitem_pair(This, key)) + if (get_keyitem_pair(dictionary, key)) return CTL_E_KEY_ALREADY_EXISTS;
- return add_keyitem_pair(This, key, item); + return add_keyitem_pair(dictionary, key, item); }
static HRESULT WINAPI dictionary_get_Count(IDictionary *iface, LONG *count) { - dictionary *This = impl_from_IDictionary(iface); + struct dictionary *dictionary = impl_from_IDictionary(iface);
- TRACE("(%p)->(%p)\n", This, count); + TRACE("%p, %p.\n", iface, count);
- *count = This->count; + *count = dictionary->count; return S_OK; }
static HRESULT WINAPI dictionary_Exists(IDictionary *iface, VARIANT *key, VARIANT_BOOL *exists) { - dictionary *This = impl_from_IDictionary(iface); + struct dictionary *dictionary = impl_from_IDictionary(iface);
- TRACE("(%p)->(%s %p)\n", This, debugstr_variant(key), exists); + TRACE("%p, %s, %p.\n", iface, debugstr_variant(key), exists);
if (!exists) return CTL_E_ILLEGALFUNCTIONCALL;
- *exists = get_keyitem_pair(This, key) != NULL ? VARIANT_TRUE : VARIANT_FALSE; + *exists = get_keyitem_pair(dictionary, key) != NULL ? VARIANT_TRUE : VARIANT_FALSE; return S_OK; }
static HRESULT WINAPI dictionary_Items(IDictionary *iface, VARIANT *items) { - dictionary *This = impl_from_IDictionary(iface); + struct dictionary *dictionary = impl_from_IDictionary(iface); struct keyitem_pair *pair; SAFEARRAYBOUND bound; SAFEARRAY *sa; @@ -579,13 +576,13 @@ static HRESULT WINAPI dictionary_Items(IDictionary *iface, VARIANT *items) HRESULT hr; LONG i;
- TRACE("(%p)->(%p)\n", This, items); + TRACE("%p, %p.\n", iface, items);
if (!items) return S_OK;
bound.lLbound = 0; - bound.cElements = This->count; + bound.cElements = dictionary->count; sa = SafeArrayCreate(VT_VARIANT, 1, &bound); if (!sa) return E_OUTOFMEMORY; @@ -597,7 +594,8 @@ static HRESULT WINAPI dictionary_Items(IDictionary *iface, VARIANT *items) }
i = 0; - LIST_FOR_EACH_ENTRY(pair, &This->pairs, struct keyitem_pair, entry) { + LIST_FOR_EACH_ENTRY(pair, &dictionary->pairs, struct keyitem_pair, entry) + { VariantCopy(&v[i], &pair->item); i++; } @@ -610,14 +608,15 @@ static HRESULT WINAPI dictionary_Items(IDictionary *iface, VARIANT *items)
static HRESULT WINAPI dictionary_put_Key(IDictionary *iface, VARIANT *key, VARIANT *newkey) { - dictionary *This = impl_from_IDictionary(iface); + struct dictionary *dictionary = impl_from_IDictionary(iface); struct keyitem_pair *pair; VARIANT empty; HRESULT hr;
- TRACE("(%p)->(%s %s)\n", This, debugstr_variant(key), debugstr_variant(newkey)); + TRACE("%p, %s, %s.\n", iface, debugstr_variant(key), debugstr_variant(newkey));
- if ((pair = get_keyitem_pair(This, key))) { + if ((pair = get_keyitem_pair(dictionary, key))) + { /* found existing pair for a key, add new pair with new key and old item and remove old pair after that */
@@ -634,7 +633,7 @@ static HRESULT WINAPI dictionary_put_Key(IDictionary *iface, VARIANT *key, VARIA
static HRESULT WINAPI dictionary_Keys(IDictionary *iface, VARIANT *keys) { - dictionary *This = impl_from_IDictionary(iface); + struct dictionary *dictionary = impl_from_IDictionary(iface); struct keyitem_pair *pair; SAFEARRAYBOUND bound; SAFEARRAY *sa; @@ -642,13 +641,13 @@ static HRESULT WINAPI dictionary_Keys(IDictionary *iface, VARIANT *keys) HRESULT hr; LONG i;
- TRACE("(%p)->(%p)\n", This, keys); + TRACE("%p, %p.\n", iface, keys);
if (!keys) return S_OK;
bound.lLbound = 0; - bound.cElements = This->count; + bound.cElements = dictionary->count; sa = SafeArrayCreate(VT_VARIANT, 1, &bound); if (!sa) return E_OUTOFMEMORY; @@ -660,7 +659,8 @@ static HRESULT WINAPI dictionary_Keys(IDictionary *iface, VARIANT *keys) }
i = 0; - LIST_FOR_EACH_ENTRY(pair, &This->pairs, struct keyitem_pair, entry) { + LIST_FOR_EACH_ENTRY(pair, &dictionary->pairs, struct keyitem_pair, entry) + { VariantCopy(&v[i], &pair->key); i++; } @@ -673,18 +673,18 @@ static HRESULT WINAPI dictionary_Keys(IDictionary *iface, VARIANT *keys)
static HRESULT WINAPI dictionary_Remove(IDictionary *iface, VARIANT *key) { - dictionary *This = impl_from_IDictionary(iface); + struct dictionary *dictionary = impl_from_IDictionary(iface); struct keyitem_pair *pair;
- TRACE("(%p)->(%s)\n", This, debugstr_variant(key)); + TRACE("%p, %s.\n", iface, debugstr_variant(key));
- if (!(pair = get_keyitem_pair(This, key))) + if (!(pair = get_keyitem_pair(dictionary, key))) return CTL_E_ELEMENT_NOT_FOUND;
- notify_remove_pair(&This->notifier, &pair->entry); + notify_remove_pair(&dictionary->notifier, &pair->entry); list_remove(&pair->entry); list_remove(&pair->bucket); - This->count--; + dictionary->count--;
free_keyitem_pair(pair); return S_OK; @@ -692,55 +692,56 @@ static HRESULT WINAPI dictionary_Remove(IDictionary *iface, VARIANT *key)
static HRESULT WINAPI dictionary_RemoveAll(IDictionary *iface) { - dictionary *This = impl_from_IDictionary(iface); + struct dictionary *dictionary = impl_from_IDictionary(iface); struct keyitem_pair *pair, *pair2;
- TRACE("(%p)\n", This); + TRACE("%p.\n", iface);
- if (This->count == 0) + if (!dictionary->count) return S_OK;
- notify_remove_pair(&This->notifier, NULL); - LIST_FOR_EACH_ENTRY_SAFE(pair, pair2, &This->pairs, struct keyitem_pair, entry) { + notify_remove_pair(&dictionary->notifier, NULL); + LIST_FOR_EACH_ENTRY_SAFE(pair, pair2, &dictionary->pairs, struct keyitem_pair, entry) + { list_remove(&pair->entry); list_remove(&pair->bucket); free_keyitem_pair(pair); } - This->count = 0; + dictionary->count = 0;
return S_OK; }
static HRESULT WINAPI dictionary_put_CompareMode(IDictionary *iface, CompareMethod method) { - dictionary *This = impl_from_IDictionary(iface); + struct dictionary *dictionary = impl_from_IDictionary(iface);
- TRACE("(%p)->(%d)\n", This, method); + TRACE("%p, %d.\n", iface, method);
- if (This->count) + if (dictionary->count) return CTL_E_ILLEGALFUNCTIONCALL;
- This->method = method; + dictionary->method = method; return S_OK; }
static HRESULT WINAPI dictionary_get_CompareMode(IDictionary *iface, CompareMethod *method) { - dictionary *This = impl_from_IDictionary(iface); + struct dictionary *dictionary = impl_from_IDictionary(iface);
- TRACE("(%p)->(%p)\n", This, method); + TRACE("%p, %p.\n", iface, method);
- *method = This->method; + *method = dictionary->method; return S_OK; }
static HRESULT WINAPI dictionary__NewEnum(IDictionary *iface, IUnknown **ret) { - dictionary *This = impl_from_IDictionary(iface); + struct dictionary *dictionary = impl_from_IDictionary(iface);
- TRACE("(%p)->(%p)\n", This, ret); + TRACE("%p, %p.\n", iface, ret);
- return create_dict_enum(This, ret); + return create_dict_enum(dictionary, ret); }
static DWORD get_str_hash(const WCHAR *str, CompareMethod method) @@ -789,16 +790,16 @@ static DWORD get_ptr_hash(void *ptr)
static HRESULT WINAPI dictionary_get_HashVal(IDictionary *iface, VARIANT *key, VARIANT *hash) { - dictionary *This = impl_from_IDictionary(iface); + struct dictionary *dictionary = impl_from_IDictionary(iface);
- TRACE("(%p)->(%s %p)\n", This, debugstr_variant(key), hash); + TRACE("%p, %s, %p.\n", iface, debugstr_variant(key), hash);
V_VT(hash) = VT_I4; switch (V_VT(key)) { case VT_BSTR|VT_BYREF: case VT_BSTR: - V_I4(hash) = get_str_hash(get_key_strptr(key), This->method); + V_I4(hash) = get_str_hash(get_key_strptr(key), dictionary->method); break; case VT_UI1|VT_BYREF: case VT_UI1: @@ -887,7 +888,7 @@ static const struct IDictionaryVtbl dictionary_vtbl =
HRESULT WINAPI Dictionary_CreateInstance(IClassFactory *factory, IUnknown *outer, REFIID riid, void **ret) { - dictionary *object; + struct dictionary *object;
TRACE("(%p, %p, %s, %p)\n", factory, outer, debugstr_guid(riid), ret);