Hello!
(Jacek, this is not directed at you but a general rant). HeapAlloc is an awful API and even its creators wrap it in a couple of DLLs. In Wine HeapAlloc gets wrapped in different places, each using a different name and even a different naming convention. This makes the code harder to understand for people that browse the code (people doing janitorial work) as they have to check every time if the function is yet another wrapper around HeapFree or if the function is doing more than that. And this makes it even harder for static code analyzing tools.
I therefor propose to standardize all the internal HeapAlloc wrappers to a common name and form, Something along the lines of: walloc() wzalloc() wrealloc() wzrealloc() wfree() It's short and concise and doesn't conflict with the Win32 API.
Comments? bye michael
Jacek Caban wrote:
diff --git a/dlls/urlmon/urlmon_main.h b/dlls/urlmon/urlmon_main.h index 6c2887e..aeb0eb2 100644 --- a/dlls/urlmon/urlmon_main.h +++ b/dlls/urlmon/urlmon_main.h @@ -63,4 +63,24 @@ HRESULT start_binding(LPCWSTR url, IBindCtx *pbc, REFIID riid, void **ppv);
HRESULT create_binding_protocol(LPCWSTR url, IInternetProtocol **protocol);
+static inline void *urlmon_alloc(size_t len) +{
- return HeapAlloc(GetProcessHeap(), 0, len);
+}
+static inline void *urlmon_alloc_zero(size_t len) +{
- return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
+}
+static inline void *urlmon_realloc(void *mem, size_t len) +{
- return HeapReAlloc(GetProcessHeap(), 0, mem, len);
+}
+static inline BOOL urlmon_free(void *mem) +{
- return HeapFree(GetProcessHeap(), 0, mem);
+}
#endif /* __WINE_URLMON_MAIN_H */
Michael Stefaniuc mstefani@redhat.com writes:
I therefor propose to standardize all the internal HeapAlloc wrappers to a common name and form, Something along the lines of: walloc() wzalloc() wrealloc() wzrealloc() wfree() It's short and concise and doesn't conflict with the Win32 API.
Standardizing them is OK, but the names aren't very good, especially walloc looks too much like malloc. It's suggest something like heap_alloc, heap_alloc_zero, etc.
Alexandre Julliard wrote:
Michael Stefaniuc mstefani@redhat.com writes:
I therefor propose to standardize all the internal HeapAlloc wrappers to a common name and form, Something along the lines of: walloc() wzalloc() wrealloc() wzrealloc() wfree() It's short and concise and doesn't conflict with the Win32 API.
Standardizing them is OK, but the names aren't very good, especially walloc looks too much like malloc. It's suggest something like heap_alloc, heap_alloc_zero, etc.
Yeah, i went for the convention used by the Linux kernel replacing 'k' with 'w'. But I don't mind how they are named as long as it is consistent.
I'll do a janitorial task page for this and start sending patches.
bye michael