Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
424e38f3
Commit
424e38f3
authored
Mar 29, 2022
by
Rémi Bernon
Committed by
Alexandre Julliard
Mar 29, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernelbase: Fix indentation of LocalReAlloc.
Signed-off-by:
Rémi Bernon
<
rbernon@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
fc12f812
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
92 deletions
+91
-92
memory.c
dlls/kernelbase/memory.c
+91
-92
No files found.
dlls/kernelbase/memory.c
View file @
424e38f3
...
...
@@ -791,98 +791,97 @@ LPVOID WINAPI DECLSPEC_HOTPATCH LocalLock( HLOCAL hmem )
*/
HLOCAL
WINAPI
DECLSPEC_HOTPATCH
LocalReAlloc
(
HLOCAL
hmem
,
SIZE_T
size
,
UINT
flags
)
{
struct
local_header
*
header
;
void
*
ptr
;
HLOCAL
ret
=
0
;
DWORD
heap_flags
=
(
flags
&
LMEM_ZEROINIT
)
?
HEAP_ZERO_MEMORY
:
0
;
RtlLockHeap
(
GetProcessHeap
()
);
if
(
flags
&
LMEM_MODIFY
)
/* modify flags */
{
if
(
is_pointer
(
hmem
)
&&
(
flags
&
LMEM_MOVEABLE
))
{
/* make a fixed block moveable
* actually only NT is able to do this. But it's soo simple
*/
if
(
hmem
==
0
)
{
WARN
(
"null handle
\n
"
);
SetLastError
(
ERROR_NOACCESS
);
}
else
{
size
=
RtlSizeHeap
(
GetProcessHeap
(),
0
,
hmem
);
ret
=
LocalAlloc
(
flags
,
size
);
ptr
=
LocalLock
(
ret
);
memcpy
(
ptr
,
hmem
,
size
);
LocalUnlock
(
ret
);
LocalFree
(
hmem
);
}
}
else
if
(
!
is_pointer
(
hmem
)
&&
(
flags
&
LMEM_DISCARDABLE
))
{
/* change the flags to make our block "discardable" */
header
=
get_header
(
hmem
);
header
->
flags
|=
LMEM_DISCARDABLE
>>
8
;
ret
=
hmem
;
}
else
SetLastError
(
ERROR_INVALID_PARAMETER
);
}
else
{
if
(
is_pointer
(
hmem
))
{
/* reallocate fixed memory */
if
(
!
(
flags
&
LMEM_MOVEABLE
))
heap_flags
|=
HEAP_REALLOC_IN_PLACE_ONLY
;
ret
=
HeapReAlloc
(
GetProcessHeap
(),
heap_flags
,
hmem
,
size
);
}
else
{
/* reallocate a moveable block */
header
=
get_header
(
hmem
);
if
(
size
!=
0
)
{
if
(
size
<=
INT_MAX
-
HLOCAL_STORAGE
)
{
if
(
header
->
ptr
)
{
if
((
ptr
=
HeapReAlloc
(
GetProcessHeap
(),
heap_flags
,
(
char
*
)
header
->
ptr
-
HLOCAL_STORAGE
,
size
+
HLOCAL_STORAGE
)))
{
header
->
ptr
=
(
char
*
)
ptr
+
HLOCAL_STORAGE
;
ret
=
hmem
;
}
}
else
{
if
((
ptr
=
HeapAlloc
(
GetProcessHeap
(),
heap_flags
,
size
+
HLOCAL_STORAGE
)))
{
*
(
HLOCAL
*
)
ptr
=
hmem
;
header
->
ptr
=
(
char
*
)
ptr
+
HLOCAL_STORAGE
;
ret
=
hmem
;
}
}
}
else
SetLastError
(
ERROR_OUTOFMEMORY
);
}
else
{
if
(
header
->
lock
==
0
)
{
if
(
header
->
ptr
)
{
HeapFree
(
GetProcessHeap
(),
0
,
(
char
*
)
header
->
ptr
-
HLOCAL_STORAGE
);
header
->
ptr
=
NULL
;
}
ret
=
hmem
;
}
else
WARN
(
"not freeing memory associated with locked handle
\n
"
);
}
}
}
RtlUnlockHeap
(
GetProcessHeap
()
);
return
ret
;
struct
local_header
*
header
;
void
*
ptr
;
HLOCAL
ret
=
0
;
DWORD
heap_flags
=
(
flags
&
LMEM_ZEROINIT
)
?
HEAP_ZERO_MEMORY
:
0
;
RtlLockHeap
(
GetProcessHeap
()
);
if
(
flags
&
LMEM_MODIFY
)
/* modify flags */
{
if
(
is_pointer
(
hmem
)
&&
(
flags
&
LMEM_MOVEABLE
))
{
/* make a fixed block moveable
* actually only NT is able to do this. But it's soo simple
*/
if
(
hmem
==
0
)
{
WARN
(
"null handle
\n
"
);
SetLastError
(
ERROR_NOACCESS
);
}
else
{
size
=
RtlSizeHeap
(
GetProcessHeap
(),
0
,
hmem
);
ret
=
LocalAlloc
(
flags
,
size
);
ptr
=
LocalLock
(
ret
);
memcpy
(
ptr
,
hmem
,
size
);
LocalUnlock
(
ret
);
LocalFree
(
hmem
);
}
}
else
if
(
!
is_pointer
(
hmem
)
&&
(
flags
&
LMEM_DISCARDABLE
))
{
/* change the flags to make our block "discardable" */
header
=
get_header
(
hmem
);
header
->
flags
|=
LMEM_DISCARDABLE
>>
8
;
ret
=
hmem
;
}
else
SetLastError
(
ERROR_INVALID_PARAMETER
);
}
else
{
if
(
is_pointer
(
hmem
))
{
/* reallocate fixed memory */
if
(
!
(
flags
&
LMEM_MOVEABLE
))
heap_flags
|=
HEAP_REALLOC_IN_PLACE_ONLY
;
ret
=
HeapReAlloc
(
GetProcessHeap
(),
heap_flags
,
hmem
,
size
);
}
else
{
/* reallocate a moveable block */
header
=
get_header
(
hmem
);
if
(
size
!=
0
)
{
if
(
size
<=
INT_MAX
-
HLOCAL_STORAGE
)
{
if
(
header
->
ptr
)
{
if
((
ptr
=
HeapReAlloc
(
GetProcessHeap
(),
heap_flags
,
(
char
*
)
header
->
ptr
-
HLOCAL_STORAGE
,
size
+
HLOCAL_STORAGE
)))
{
header
->
ptr
=
(
char
*
)
ptr
+
HLOCAL_STORAGE
;
ret
=
hmem
;
}
}
else
{
if
((
ptr
=
HeapAlloc
(
GetProcessHeap
(),
heap_flags
,
size
+
HLOCAL_STORAGE
)))
{
*
(
HLOCAL
*
)
ptr
=
hmem
;
header
->
ptr
=
(
char
*
)
ptr
+
HLOCAL_STORAGE
;
ret
=
hmem
;
}
}
}
else
SetLastError
(
ERROR_OUTOFMEMORY
);
}
else
{
if
(
header
->
lock
==
0
)
{
if
(
header
->
ptr
)
{
HeapFree
(
GetProcessHeap
(),
0
,
(
char
*
)
header
->
ptr
-
HLOCAL_STORAGE
);
header
->
ptr
=
NULL
;
}
ret
=
hmem
;
}
else
WARN
(
"not freeing memory associated with locked handle
\n
"
);
}
}
}
RtlUnlockHeap
(
GetProcessHeap
()
);
return
ret
;
}
...
...
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