Hans Leidekker : wmiutils: Introduce memory allocation helpers.

Alexandre Julliard julliard at winehq.org
Wed Jan 2 14:18:39 CST 2013


Module: wine
Branch: master
Commit: 0ee1b888a2cb61b991f0abc7d8e73115d20c9a4c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0ee1b888a2cb61b991f0abc7d8e73115d20c9a4c

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Wed Jan  2 13:33:10 2013 +0100

wmiutils: Introduce memory allocation helpers.

---

 dlls/wmiutils/path.c             |    9 ++++-----
 dlls/wmiutils/statuscode.c       |    5 ++---
 dlls/wmiutils/wmiutils_private.h |   11 +++++++++++
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/dlls/wmiutils/path.c b/dlls/wmiutils/path.c
index b8c0f3e..a4f3870 100644
--- a/dlls/wmiutils/path.c
+++ b/dlls/wmiutils/path.c
@@ -61,8 +61,8 @@ static ULONG WINAPI path_Release(
     if (!refs)
     {
         TRACE("destroying %p\n", path);
-        HeapFree( GetProcessHeap(), 0, path->text );
-        HeapFree( GetProcessHeap(), 0, path );
+        heap_free( path->text );
+        heap_free( path );
     }
     return refs;
 }
@@ -103,8 +103,7 @@ static HRESULT WINAPI path_SetText(
     if (uMode) FIXME("igoring mode %u\n", uMode);
 
     len = strlenW( pszPath );
-    if (!(path->text = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) )))
-        return E_OUTOFMEMORY;
+    if (!(path->text = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return E_OUTOFMEMORY;
 
     strcpyW( path->text, pszPath );
     path->len = len;
@@ -382,7 +381,7 @@ HRESULT WbemPath_create( IUnknown *pUnkOuter, LPVOID *ppObj )
 
     TRACE("%p, %p\n", pUnkOuter, ppObj);
 
-    if (!(path = HeapAlloc( GetProcessHeap(), 0, sizeof(*path) ))) return E_OUTOFMEMORY;
+    if (!(path = heap_alloc( sizeof(*path) ))) return E_OUTOFMEMORY;
 
     path->IWbemPath_iface.lpVtbl = &path_vtbl;
     path->refs = 1;
diff --git a/dlls/wmiutils/statuscode.c b/dlls/wmiutils/statuscode.c
index 2d8a3f8..0718c17 100644
--- a/dlls/wmiutils/statuscode.c
+++ b/dlls/wmiutils/statuscode.c
@@ -59,7 +59,7 @@ static ULONG WINAPI status_code_Release(
     if (!refs)
     {
         TRACE("destroying %p\n", status_code);
-        HeapFree( GetProcessHeap(), 0, status_code );
+        heap_free( status_code );
     }
     return refs;
 }
@@ -138,8 +138,7 @@ HRESULT WbemStatusCodeText_create( IUnknown *pUnkOuter, LPVOID *ppObj )
 
     TRACE("(%p,%p)\n", pUnkOuter, ppObj);
 
-    sc = HeapAlloc( GetProcessHeap(), 0, sizeof(*sc) );
-    if (!sc) return E_OUTOFMEMORY;
+    if (!(sc = heap_alloc( sizeof(*sc) ))) return E_OUTOFMEMORY;
 
     sc->IWbemStatusCodeText_iface.lpVtbl = &status_code_vtbl;
     sc->refs = 1;
diff --git a/dlls/wmiutils/wmiutils_private.h b/dlls/wmiutils/wmiutils_private.h
index fdcd48f..fdfca13 100644
--- a/dlls/wmiutils/wmiutils_private.h
+++ b/dlls/wmiutils/wmiutils_private.h
@@ -18,3 +18,14 @@
 
 HRESULT WbemPath_create(IUnknown *, LPVOID *) DECLSPEC_HIDDEN;
 HRESULT WbemStatusCodeText_create(IUnknown *, LPVOID *) DECLSPEC_HIDDEN;
+
+static void *heap_alloc( size_t len ) __WINE_ALLOC_SIZE(1);
+static inline void *heap_alloc( size_t len )
+{
+    return HeapAlloc( GetProcessHeap(), 0, len );
+}
+
+static inline BOOL heap_free( void *mem )
+{
+    return HeapFree( GetProcessHeap(), 0, mem );
+}




More information about the wine-cvs mailing list