Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
4c25f649
Commit
4c25f649
authored
Aug 02, 2017
by
Hugh McMaster
Committed by
Alexandre Julliard
Aug 02, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
regedit: Use the heap_*() functions in hexedit.c where possible.
Signed-off-by:
Hugh McMaster
<
hugh.mcmaster@outlook.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
3bca09ee
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
29 deletions
+27
-29
hexedit.c
programs/regedit/hexedit.c
+27
-29
No files found.
programs/regedit/hexedit.c
View file @
4c25f649
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
*/
*/
#include <stdarg.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
#include <assert.h>
#include <assert.h>
...
@@ -35,6 +36,7 @@
...
@@ -35,6 +36,7 @@
#include "commctrl.h"
#include "commctrl.h"
#include "main.h"
#include "main.h"
#include "regproc.h"
/* spaces dividing hex and ASCII */
/* spaces dividing hex and ASCII */
#define DIV_SPACES 4
#define DIV_SPACES 4
...
@@ -74,13 +76,9 @@ static LPWSTR HexEdit_GetLineText(BYTE *pData, LONG cbData, LONG pad)
...
@@ -74,13 +76,9 @@ static LPWSTR HexEdit_GetLineText(BYTE *pData, LONG cbData, LONG pad)
{
{
static
const
WCHAR
percent_02xW
[]
=
{
'%'
,
'0'
,
'2'
,
'X'
,
' '
,
0
};
static
const
WCHAR
percent_02xW
[]
=
{
'%'
,
'0'
,
'2'
,
'X'
,
' '
,
0
};
LPWSTR
lpszLine
=
HeapAlloc
(
GetProcessHeap
(),
0
,
WCHAR
*
lpszLine
=
heap_xalloc
((
cbData
*
3
+
pad
*
3
+
DIV_SPACES
+
cbData
+
1
)
*
sizeof
(
WCHAR
));
(
cbData
*
3
+
pad
*
3
+
DIV_SPACES
+
cbData
+
1
)
*
sizeof
(
WCHAR
));
LONG
i
;
LONG
i
;
if
(
!
lpszLine
)
return
NULL
;
for
(
i
=
0
;
i
<
cbData
;
i
++
)
for
(
i
=
0
;
i
<
cbData
;
i
++
)
wsprintfW
(
lpszLine
+
i
*
3
,
percent_02xW
,
pData
[
i
]);
wsprintfW
(
lpszLine
+
i
*
3
,
percent_02xW
,
pData
[
i
]);
for
(
i
=
0
;
i
<
pad
*
3
;
i
++
)
for
(
i
=
0
;
i
<
pad
*
3
;
i
++
)
...
@@ -139,7 +137,7 @@ HexEdit_Paint(HEXEDIT_INFO *infoPtr)
...
@@ -139,7 +137,7 @@ HexEdit_Paint(HEXEDIT_INFO *infoPtr)
TextOutW
(
hdc
,
nXStart
,
nYStart
,
lpszLine
,
infoPtr
->
nBytesPerLine
*
3
+
DIV_SPACES
+
nLineLen
);
TextOutW
(
hdc
,
nXStart
,
nYStart
,
lpszLine
,
infoPtr
->
nBytesPerLine
*
3
+
DIV_SPACES
+
nLineLen
);
nYStart
+=
infoPtr
->
nHeight
;
nYStart
+=
infoPtr
->
nHeight
;
HeapFree
(
GetProcessHeap
(),
0
,
lpszLine
);
heap_free
(
lpszLine
);
}
}
SelectObject
(
hdc
,
hOldFont
);
SelectObject
(
hdc
,
hOldFont
);
...
@@ -178,7 +176,7 @@ HexEdit_UpdateCaret(HEXEDIT_INFO *infoPtr)
...
@@ -178,7 +176,7 @@ HexEdit_UpdateCaret(HEXEDIT_INFO *infoPtr)
if
(
!
nLineLen
)
size
.
cx
=
0
;
if
(
!
nLineLen
)
size
.
cx
=
0
;
HeapFree
(
GetProcessHeap
(),
0
,
lpszLine
);
heap_free
(
lpszLine
);
SetCaretPos
(
SetCaretPos
(
GetSystemMetrics
(
SM_CXBORDER
)
+
size
.
cx
,
GetSystemMetrics
(
SM_CXBORDER
)
+
size
.
cx
,
...
@@ -230,22 +228,18 @@ HexEdit_EnsureVisible(HEXEDIT_INFO *infoPtr, INT nCaretPos)
...
@@ -230,22 +228,18 @@ HexEdit_EnsureVisible(HEXEDIT_INFO *infoPtr, INT nCaretPos)
static
LRESULT
static
LRESULT
HexEdit_SetData
(
HEXEDIT_INFO
*
infoPtr
,
INT
cbData
,
const
BYTE
*
pData
)
HexEdit_SetData
(
HEXEDIT_INFO
*
infoPtr
,
INT
cbData
,
const
BYTE
*
pData
)
{
{
HeapFree
(
GetProcessHeap
(),
0
,
infoPtr
->
pData
);
heap_free
(
infoPtr
->
pData
);
infoPtr
->
cbData
=
0
;
infoPtr
->
cbData
=
0
;
infoPtr
->
pData
=
HeapAlloc
(
GetProcessHeap
(),
0
,
cbData
);
infoPtr
->
pData
=
heap_xalloc
(
cbData
);
if
(
infoPtr
->
pData
)
memcpy
(
infoPtr
->
pData
,
pData
,
cbData
);
{
infoPtr
->
cbData
=
cbData
;
memcpy
(
infoPtr
->
pData
,
pData
,
cbData
);
infoPtr
->
cbData
=
cbData
;
infoPtr
->
nCaretPos
=
0
;
infoPtr
->
nCaretPos
=
0
;
HexEdit_UpdateScrollbars
(
infoPtr
);
HexEdit_UpdateScrollbars
(
infoPtr
);
HexEdit_UpdateCaret
(
infoPtr
);
HexEdit_UpdateCaret
(
infoPtr
);
InvalidateRect
(
infoPtr
->
hwndSelf
,
NULL
,
TRUE
);
InvalidateRect
(
infoPtr
->
hwndSelf
,
NULL
,
TRUE
);
return
TRUE
;
return
TRUE
;
}
return
FALSE
;
}
}
static
LRESULT
static
LRESULT
...
@@ -296,8 +290,8 @@ HexEdit_Char (HEXEDIT_INFO *infoPtr, WCHAR ch)
...
@@ -296,8 +290,8 @@ HexEdit_Char (HEXEDIT_INFO *infoPtr, WCHAR ch)
{
{
/* make room for another byte */
/* make room for another byte */
infoPtr
->
cbData
++
;
infoPtr
->
cbData
++
;
infoPtr
->
pData
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
infoPtr
->
pData
,
infoPtr
->
cbData
+
1
);
infoPtr
->
pData
=
heap_xrealloc
(
infoPtr
->
pData
,
infoPtr
->
cbData
+
1
);
if
(
!
infoPtr
->
pData
)
return
0
;
/* move everything after caret up one byte */
/* move everything after caret up one byte */
memmove
(
infoPtr
->
pData
+
nCaretBytePos
+
1
,
memmove
(
infoPtr
->
pData
+
nCaretBytePos
+
1
,
infoPtr
->
pData
+
nCaretBytePos
,
infoPtr
->
pData
+
nCaretBytePos
,
...
@@ -348,9 +342,9 @@ static inline LRESULT
...
@@ -348,9 +342,9 @@ static inline LRESULT
HexEdit_Destroy
(
HEXEDIT_INFO
*
infoPtr
)
HexEdit_Destroy
(
HEXEDIT_INFO
*
infoPtr
)
{
{
HWND
hwnd
=
infoPtr
->
hwndSelf
;
HWND
hwnd
=
infoPtr
->
hwndSelf
;
HeapFree
(
GetProcessHeap
(),
0
,
infoPtr
->
pData
);
heap_free
(
infoPtr
->
pData
);
/* free info data */
/* free info data */
HeapFree
(
GetProcessHeap
(),
0
,
infoPtr
);
heap_free
(
infoPtr
);
SetWindowLongPtrW
(
hwnd
,
0
,
0
);
SetWindowLongPtrW
(
hwnd
,
0
,
0
);
return
0
;
return
0
;
}
}
...
@@ -478,7 +472,8 @@ static inline LRESULT HexEdit_NCCreate (HWND hwnd, LPCREATESTRUCTW lpcs)
...
@@ -478,7 +472,8 @@ static inline LRESULT HexEdit_NCCreate (HWND hwnd, LPCREATESTRUCTW lpcs)
lpcs
->
dwExStyle
|
WS_EX_CLIENTEDGE
);
lpcs
->
dwExStyle
|
WS_EX_CLIENTEDGE
);
/* allocate memory for info structure */
/* allocate memory for info structure */
infoPtr
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
HEXEDIT_INFO
));
infoPtr
=
heap_xalloc
(
sizeof
(
HEXEDIT_INFO
));
memset
(
infoPtr
,
0
,
sizeof
(
HEXEDIT_INFO
));
SetWindowLongPtrW
(
hwnd
,
0
,
(
DWORD_PTR
)
infoPtr
);
SetWindowLongPtrW
(
hwnd
,
0
,
(
DWORD_PTR
)
infoPtr
);
/* initialize info structure */
/* initialize info structure */
...
@@ -526,12 +521,15 @@ HexEdit_SetFont (HEXEDIT_INFO *infoPtr, HFONT hFont, BOOL redraw)
...
@@ -526,12 +521,15 @@ HexEdit_SetFont (HEXEDIT_INFO *infoPtr, HFONT hFont, BOOL redraw)
for
(
i
=
0
;
;
i
++
)
for
(
i
=
0
;
;
i
++
)
{
{
BYTE
*
pData
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
i
);
BYTE
*
pData
=
heap_xalloc
(
i
);
LPWSTR
lpszLine
=
HexEdit_GetLineText
(
pData
,
i
,
0
)
;
WCHAR
*
lpszLine
;
SIZE
size
;
SIZE
size
;
memset
(
pData
,
0
,
i
);
lpszLine
=
HexEdit_GetLineText
(
pData
,
i
,
0
);
GetTextExtentPoint32W
(
hdc
,
lpszLine
,
lstrlenW
(
lpszLine
),
&
size
);
GetTextExtentPoint32W
(
hdc
,
lpszLine
,
lstrlenW
(
lpszLine
),
&
size
);
HeapFree
(
GetProcessHeap
(),
0
,
lpszLine
);
heap_free
(
lpszLine
);
HeapFree
(
GetProcessHeap
(),
0
,
pData
);
heap_free
(
pData
);
if
(
size
.
cx
>
(
rcClient
.
right
-
rcClient
.
left
))
if
(
size
.
cx
>
(
rcClient
.
right
-
rcClient
.
left
))
{
{
infoPtr
->
nBytesPerLine
=
i
-
1
;
infoPtr
->
nBytesPerLine
=
i
-
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment