comctl32 comctl32undoc.c

Ge van Geldorp ge at gse.nl
Thu Jan 22 13:35:37 CST 2004


Changelog:
  Sync with ReactOS 0.2
  Use process heap instead of private heap for DPA allocations, since the
  private heap might be destroyed before all DPA allocations are freed.
  Remove some code duplication.

Index: dlls/comctl32/comctl32undoc.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/comctl32undoc.c,v
retrieving revision 1.86
diff -u -r1.86 comctl32undoc.c
--- dlls/comctl32/comctl32undoc.c	20 Nov 2003 04:19:41 -0000	1.86
+++ dlls/comctl32/comctl32undoc.c	22 Jan 2004 19:21:41 -0000
@@ -1655,11 +1655,15 @@
  * pointers.
  */
 
+
 /**************************************************************************
- * DPA_Create [COMCTL32.328] Creates a dynamic pointer array
+ * DPA_CreateEx [COMCTL32.340]
+ *
+ * Creates a dynamic pointer array using the specified size and heap.
  *
  * PARAMS
  *     nGrow [I] number of items by which the array grows when it is filled
+ *     hHeap [I] handle to the heap where the array is stored
  *
  * RETURNS
  *     Success: handle (pointer) to the pointer array.
@@ -1667,18 +1671,24 @@
  */
 
 HDPA WINAPI
-DPA_Create (INT nGrow)
+DPA_CreateEx (INT nGrow, HANDLE hHeap)
 {
     HDPA hdpa;
 
-    TRACE("(%d)\n", nGrow);
+    TRACE("(%d %p)\n", nGrow, hHeap);
+
+    if (hHeap)
+	hdpa = (HDPA)HeapAlloc (hHeap, HEAP_ZERO_MEMORY, sizeof(*hdpa));
+    else
+	hdpa = Alloc (sizeof(*hdpa));
 
-    hdpa = Alloc (sizeof(*hdpa));
     if (hdpa) {
-	hdpa->nGrow = max(8, nGrow);
-	hdpa->hHeap = COMCTL32_hHeap;
+	hdpa->nGrow = min(8, nGrow);
+	hdpa->hHeap = hHeap ? hHeap : COMCTL32_hHeap;
 	hdpa->nMaxCount = hdpa->nGrow * 2;
-	hdpa->ptrs = Alloc (hdpa->nMaxCount * sizeof(LPVOID));
+	hdpa->ptrs =
+	    (LPVOID*)HeapAlloc (hHeap, HEAP_ZERO_MEMORY,
+				hdpa->nMaxCount * sizeof(LPVOID));
     }
 
     TRACE("-- %p\n", hdpa);
@@ -1688,6 +1698,24 @@
 
 
 /**************************************************************************
+ * DPA_Create [COMCTL32.328] Creates a dynamic pointer array
+ *
+ * PARAMS
+ *     nGrow [I] number of items by which the array grows when it is filled
+ *
+ * RETURNS
+ *     Success: handle (pointer) to the pointer array.
+ *     Failure: NULL
+ */
+
+HDPA WINAPI
+DPA_Create (INT nGrow)
+{
+    return DPA_CreateEx (nGrow, GetProcessHeap());
+}
+
+
+/**************************************************************************
  * DPA_Destroy [COMCTL32.329] Destroys a dynamic pointer array
  *
  * PARAMS
@@ -2221,47 +2249,6 @@
 
     TRACE("-- not found: ret=-1\n");
     return -1;
-}
-
-
-/**************************************************************************
- * DPA_CreateEx [COMCTL32.340]
- *
- * Creates a dynamic pointer array using the specified size and heap.
- *
- * PARAMS
- *     nGrow [I] number of items by which the array grows when it is filled
- *     hHeap [I] handle to the heap where the array is stored
- *
- * RETURNS
- *     Success: handle (pointer) to the pointer array.
- *     Failure: NULL
- */
-
-HDPA WINAPI
-DPA_CreateEx (INT nGrow, HANDLE hHeap)
-{
-    HDPA hdpa;
-
-    TRACE("(%d %p)\n", nGrow, hHeap);
-
-    if (hHeap)
-	hdpa = (HDPA)HeapAlloc (hHeap, HEAP_ZERO_MEMORY, sizeof(*hdpa));
-    else
-	hdpa = Alloc (sizeof(*hdpa));
-
-    if (hdpa) {
-	hdpa->nGrow = min(8, nGrow);
-	hdpa->hHeap = hHeap ? hHeap : COMCTL32_hHeap;
-	hdpa->nMaxCount = hdpa->nGrow * 2;
-	hdpa->ptrs =
-	    (LPVOID*)HeapAlloc (hHeap, HEAP_ZERO_MEMORY,
-				hdpa->nMaxCount * sizeof(LPVOID));
-    }
-
-    TRACE("-- %p\n", hdpa);
-
-    return hdpa;
 }
 
 



More information about the wine-patches mailing list