Commit 8fe1c228 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/header: Use CRT allocation functions.

parent 41b4d9b3
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
#include "vssym32.h" #include "vssym32.h"
#include "uxtheme.h" #include "uxtheme.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(header); WINE_DEFAULT_DEBUG_CHANNEL(header);
...@@ -141,7 +140,7 @@ static void HEADER_StoreHDItemInHeader(HEADER_ITEM *lpItem, UINT mask, const HDI ...@@ -141,7 +140,7 @@ static void HEADER_StoreHDItemInHeader(HEADER_ITEM *lpItem, UINT mask, const HDI
if (mask & HDI_TEXT) if (mask & HDI_TEXT)
{ {
heap_free(lpItem->pszText); free(lpItem->pszText);
lpItem->pszText = NULL; lpItem->pszText = NULL;
if (phdi->pszText != LPSTR_TEXTCALLBACKW) /* covers != TEXTCALLBACKA too */ if (phdi->pszText != LPSTR_TEXTCALLBACKW) /* covers != TEXTCALLBACKA too */
...@@ -336,7 +335,7 @@ static HRGN create_sort_arrow( INT x, INT y, INT h, BOOL is_up ) ...@@ -336,7 +335,7 @@ static HRGN create_sort_arrow( INT x, INT y, INT h, BOOL is_up )
if (size > sizeof(buffer)) if (size > sizeof(buffer))
{ {
data = heap_alloc( size ); data = malloc( size );
if (!data) return NULL; if (!data) return NULL;
} }
data->rdh.dwSize = sizeof(data->rdh); data->rdh.dwSize = sizeof(data->rdh);
...@@ -362,7 +361,7 @@ static HRGN create_sort_arrow( INT x, INT y, INT h, BOOL is_up ) ...@@ -362,7 +361,7 @@ static HRGN create_sort_arrow( INT x, INT y, INT h, BOOL is_up )
data->rdh.nCount++; data->rdh.nCount++;
} }
rgn = ExtCreateRegion( NULL, size, data ); rgn = ExtCreateRegion( NULL, size, data );
if (data != (RGNDATA *)buffer) heap_free( data ); if (data != (RGNDATA *)buffer) free( data );
return rgn; return rgn;
} }
...@@ -983,7 +982,7 @@ HEADER_PrepareCallbackItems(const HEADER_INFO *infoPtr, INT iItem, INT reqMask) ...@@ -983,7 +982,7 @@ HEADER_PrepareCallbackItems(const HEADER_INFO *infoPtr, INT iItem, INT reqMask)
if (mask&HDI_TEXT && lpItem->pszText != NULL) if (mask&HDI_TEXT && lpItem->pszText != NULL)
{ {
ERR("(): function called without a call to FreeCallbackItems\n"); ERR("(): function called without a call to FreeCallbackItems\n");
heap_free(lpItem->pszText); free(lpItem->pszText);
lpItem->pszText = NULL; lpItem->pszText = NULL;
} }
...@@ -994,13 +993,13 @@ HEADER_PrepareCallbackItems(const HEADER_INFO *infoPtr, INT iItem, INT reqMask) ...@@ -994,13 +993,13 @@ HEADER_PrepareCallbackItems(const HEADER_INFO *infoPtr, INT iItem, INT reqMask)
{ {
dispInfo.hdr.code = HDN_GETDISPINFOW; dispInfo.hdr.code = HDN_GETDISPINFOW;
if (mask & HDI_TEXT) if (mask & HDI_TEXT)
pvBuffer = heap_alloc_zero(MAX_HEADER_TEXT_LEN * sizeof(WCHAR)); pvBuffer = calloc(MAX_HEADER_TEXT_LEN, sizeof(WCHAR));
} }
else else
{ {
dispInfo.hdr.code = HDN_GETDISPINFOA; dispInfo.hdr.code = HDN_GETDISPINFOA;
if (mask & HDI_TEXT) if (mask & HDI_TEXT)
pvBuffer = heap_alloc_zero(MAX_HEADER_TEXT_LEN * sizeof(CHAR)); pvBuffer = calloc(MAX_HEADER_TEXT_LEN, sizeof(CHAR));
} }
dispInfo.pszText = pvBuffer; dispInfo.pszText = pvBuffer;
dispInfo.cchTextMax = (pvBuffer!=NULL?MAX_HEADER_TEXT_LEN:0); dispInfo.cchTextMax = (pvBuffer!=NULL?MAX_HEADER_TEXT_LEN:0);
...@@ -1031,7 +1030,7 @@ HEADER_PrepareCallbackItems(const HEADER_INFO *infoPtr, INT iItem, INT reqMask) ...@@ -1031,7 +1030,7 @@ HEADER_PrepareCallbackItems(const HEADER_INFO *infoPtr, INT iItem, INT reqMask)
else else
{ {
Str_SetPtrAtoW(&lpItem->pszText, (LPSTR)dispInfo.pszText); Str_SetPtrAtoW(&lpItem->pszText, (LPSTR)dispInfo.pszText);
heap_free(pvBuffer); free(pvBuffer);
} }
} }
...@@ -1057,7 +1056,7 @@ HEADER_FreeCallbackItems(HEADER_ITEM *lpItem) ...@@ -1057,7 +1056,7 @@ HEADER_FreeCallbackItems(HEADER_ITEM *lpItem)
{ {
if (lpItem->callbackMask&HDI_TEXT) if (lpItem->callbackMask&HDI_TEXT)
{ {
heap_free(lpItem->pszText); free(lpItem->pszText);
lpItem->pszText = NULL; lpItem->pszText = NULL;
} }
...@@ -1179,15 +1178,15 @@ HEADER_DeleteItem (HEADER_INFO *infoPtr, INT iItem) ...@@ -1179,15 +1178,15 @@ HEADER_DeleteItem (HEADER_INFO *infoPtr, INT iItem)
TRACE("%d: order=%d, iOrder=%d, ->iOrder=%d\n", i, infoPtr->order[i], infoPtr->items[i].iOrder, infoPtr->items[infoPtr->order[i]].iOrder); TRACE("%d: order=%d, iOrder=%d, ->iOrder=%d\n", i, infoPtr->order[i], infoPtr->items[i].iOrder, infoPtr->items[infoPtr->order[i]].iOrder);
iOrder = infoPtr->items[iItem].iOrder; iOrder = infoPtr->items[iItem].iOrder;
heap_free(infoPtr->items[iItem].pszText); free(infoPtr->items[iItem].pszText);
infoPtr->uNumItem--; infoPtr->uNumItem--;
memmove(&infoPtr->items[iItem], &infoPtr->items[iItem + 1], memmove(&infoPtr->items[iItem], &infoPtr->items[iItem + 1],
(infoPtr->uNumItem - iItem) * sizeof(HEADER_ITEM)); (infoPtr->uNumItem - iItem) * sizeof(HEADER_ITEM));
memmove(&infoPtr->order[iOrder], &infoPtr->order[iOrder + 1], memmove(&infoPtr->order[iOrder], &infoPtr->order[iOrder + 1],
(infoPtr->uNumItem - iOrder) * sizeof(INT)); (infoPtr->uNumItem - iOrder) * sizeof(INT));
infoPtr->items = heap_realloc(infoPtr->items, sizeof(HEADER_ITEM) * infoPtr->uNumItem); infoPtr->items = realloc(infoPtr->items, sizeof(HEADER_ITEM) * infoPtr->uNumItem);
infoPtr->order = heap_realloc(infoPtr->order, sizeof(INT) * infoPtr->uNumItem); infoPtr->order = realloc(infoPtr->order, sizeof(INT) * infoPtr->uNumItem);
/* Correct the orders */ /* Correct the orders */
for (i = 0; i < infoPtr->uNumItem; i++) for (i = 0; i < infoPtr->uNumItem; i++)
...@@ -1417,8 +1416,8 @@ HEADER_InsertItemT (HEADER_INFO *infoPtr, INT nItem, const HDITEMW *phdi, BOOL b ...@@ -1417,8 +1416,8 @@ HEADER_InsertItemT (HEADER_INFO *infoPtr, INT nItem, const HDITEMW *phdi, BOOL b
iOrder = infoPtr->uNumItem; iOrder = infoPtr->uNumItem;
infoPtr->uNumItem++; infoPtr->uNumItem++;
infoPtr->items = heap_realloc(infoPtr->items, sizeof(HEADER_ITEM) * infoPtr->uNumItem); infoPtr->items = realloc(infoPtr->items, sizeof(HEADER_ITEM) * infoPtr->uNumItem);
infoPtr->order = heap_realloc(infoPtr->order, sizeof(INT) * infoPtr->uNumItem); infoPtr->order = realloc(infoPtr->order, sizeof(INT) * infoPtr->uNumItem);
/* make space for the new item */ /* make space for the new item */
memmove(&infoPtr->items[nItem + 1], &infoPtr->items[nItem], memmove(&infoPtr->items[nItem + 1], &infoPtr->items[nItem],
...@@ -1537,7 +1536,7 @@ HEADER_SetItemT (HEADER_INFO *infoPtr, INT nItem, const HDITEMW *phdi, BOOL bUni ...@@ -1537,7 +1536,7 @@ HEADER_SetItemT (HEADER_INFO *infoPtr, INT nItem, const HDITEMW *phdi, BOOL bUni
HEADER_CopyHDItemForNotify(infoPtr, &hdNotify, phdi, bUnicode, &pvScratch); HEADER_CopyHDItemForNotify(infoPtr, &hdNotify, phdi, bUnicode, &pvScratch);
if (HEADER_SendNotifyWithHDItemT(infoPtr, HDN_ITEMCHANGINGW, nItem, &hdNotify)) if (HEADER_SendNotifyWithHDItemT(infoPtr, HDN_ITEMCHANGINGW, nItem, &hdNotify))
{ {
heap_free(pvScratch); free(pvScratch);
return FALSE; return FALSE;
} }
...@@ -1554,7 +1553,7 @@ HEADER_SetItemT (HEADER_INFO *infoPtr, INT nItem, const HDITEMW *phdi, BOOL bUni ...@@ -1554,7 +1553,7 @@ HEADER_SetItemT (HEADER_INFO *infoPtr, INT nItem, const HDITEMW *phdi, BOOL bUni
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
heap_free(pvScratch); free(pvScratch);
return TRUE; return TRUE;
} }
...@@ -1577,7 +1576,7 @@ HEADER_Create (HWND hwnd, const CREATESTRUCTW *lpcs) ...@@ -1577,7 +1576,7 @@ HEADER_Create (HWND hwnd, const CREATESTRUCTW *lpcs)
HFONT hOldFont; HFONT hOldFont;
HDC hdc; HDC hdc;
infoPtr = heap_alloc_zero (sizeof(*infoPtr)); infoPtr = calloc(1, sizeof(*infoPtr));
SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr); SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
infoPtr->hwndSelf = hwnd; infoPtr->hwndSelf = hwnd;
...@@ -1632,14 +1631,14 @@ HEADER_NCDestroy (HEADER_INFO *infoPtr) ...@@ -1632,14 +1631,14 @@ HEADER_NCDestroy (HEADER_INFO *infoPtr)
if (infoPtr->items) { if (infoPtr->items) {
lpItem = infoPtr->items; lpItem = infoPtr->items;
for (nItem = 0; nItem < infoPtr->uNumItem; nItem++, lpItem++) for (nItem = 0; nItem < infoPtr->uNumItem; nItem++, lpItem++)
heap_free(lpItem->pszText); free(lpItem->pszText);
heap_free(infoPtr->items); free(infoPtr->items);
} }
heap_free(infoPtr->order); free(infoPtr->order);
SetWindowLongPtrW (infoPtr->hwndSelf, 0, 0); SetWindowLongPtrW (infoPtr->hwndSelf, 0, 0);
heap_free(infoPtr); free(infoPtr);
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment