urlmon: Wrap heap functions.

Michael Stefaniuc mstefani at redhat.com
Mon Nov 26 04:38:55 CST 2007


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                           Tel.: +49-711-96437-199
Consulting Communications Engineer          Fax.: +49-711-96437-111
--------------------------------------------------------------------
Reg. Adresse: Red Hat GmbH, Hauptstätter Strasse 58, 70178 Stuttgart
Handelsregister: Amtsgericht Stuttgart HRB 153243
Geschäftsführer: Brendan Lane, Charlie Peters, Michael Cunningham,
                 Werner Knoblich



More information about the wine-devel mailing list