Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Johnny Cai
wine
Commits
61d32b4e
Commit
61d32b4e
authored
24 years ago
by
Alexandre Julliard
Browse files
Options
Downloads
Patches
Plain Diff
Allocations do not need to be on the system heap.
parent
16ac06ed
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
files/dos_fs.c
+3
-3
3 additions, 3 deletions
files/dos_fs.c
memory/global.c
+17
-57
17 additions, 57 deletions
memory/global.c
with
20 additions
and
60 deletions
files/dos_fs.c
+
3
−
3
View file @
61d32b4e
...
...
@@ -2258,7 +2258,7 @@ HANDLE16 WINAPI FindFirstFile16( LPCSTR path, WIN32_FIND_DATAA *data )
if
(
!
(
handle
=
GlobalAlloc16
(
GMEM_MOVEABLE
,
sizeof
(
FIND_FIRST_INFO
)
)))
return
INVALID_HANDLE_VALUE16
;
info
=
(
FIND_FIRST_INFO
*
)
GlobalLock16
(
handle
);
info
->
path
=
HEAP_strdupA
(
System
Heap
,
0
,
full_name
.
long_name
);
info
->
path
=
HEAP_strdupA
(
GetProcess
Heap
()
,
0
,
full_name
.
long_name
);
info
->
long_mask
=
strrchr
(
info
->
path
,
'/'
);
if
(
info
->
long_mask
)
*
(
info
->
long_mask
++
)
=
'\0'
;
...
...
@@ -2302,7 +2302,7 @@ BOOL16 WINAPI FindNextFile16( HANDLE16 handle, WIN32_FIND_DATAA *data )
if
(
!
DOSFS_FindNextEx
(
info
,
data
))
{
DOSFS_CloseDir
(
info
->
dir
);
info
->
dir
=
NULL
;
HeapFree
(
System
Heap
,
0
,
info
->
path
);
HeapFree
(
GetProcess
Heap
()
,
0
,
info
->
path
);
info
->
path
=
info
->
long_mask
=
NULL
;
SetLastError
(
ERROR_NO_MORE_FILES
);
return
FALSE
;
...
...
@@ -2324,7 +2324,7 @@ BOOL16 WINAPI FindClose16( HANDLE16 handle )
return
FALSE
;
}
if
(
info
->
dir
)
DOSFS_CloseDir
(
info
->
dir
);
if
(
info
->
path
)
HeapFree
(
System
Heap
,
0
,
info
->
path
);
if
(
info
->
path
)
HeapFree
(
GetProcess
Heap
()
,
0
,
info
->
path
);
GlobalUnlock16
(
handle
);
GlobalFree16
(
handle
);
return
TRUE
;
...
...
This diff is collapsed.
Click to expand it.
memory/global.c
+
17
−
57
View file @
61d32b4e
...
...
@@ -991,34 +991,6 @@ typedef struct __GLOBAL32_INTERN
BYTE
LockCount
;
}
GLOBAL32_INTERN
,
*
PGLOBAL32_INTERN
;
/***********************************************************************
* GLOBAL_GetHeap
*
* Returns the appropriate heap to be used. If the object was created
* With GMEM_DDESHARE we allocated it on the system heap.
*/
static
HANDLE
GLOBAL_GetHeap
(
HGLOBAL
hmem
)
{
HANDLE
heap
;
TRACE
(
"() hmem=%x
\n
"
,
hmem
);
/* Get the appropriate heap to be used for this object */
if
(
ISPOINTER
(
hmem
))
heap
=
GetProcessHeap
();
else
{
PGLOBAL32_INTERN
pintern
;
pintern
=
HANDLE_TO_INTERN
(
hmem
);
/* If it was DDESHARE it was created on the shared system heap */
pintern
=
HANDLE_TO_INTERN
(
hmem
);
heap
=
(
pintern
->
Flags
&
(
GMEM_DDESHARE
>>
8
)
)
?
SystemHeap
:
GetProcessHeap
();
}
return
heap
;
}
/***********************************************************************
* GlobalAlloc (KERNEL32.315)
...
...
@@ -1048,19 +1020,14 @@ HGLOBAL WINAPI GlobalAlloc(
}
else
/* HANDLE */
{
HANDLE
heap
;
/* If DDESHARE is set, create on the shared system heap */
heap
=
(
flags
&
GMEM_DDESHARE
)
?
SystemHeap
:
GetProcessHeap
();
/* HeapLock(heap); */
pintern
=
HeapAlloc
(
h
eap
,
0
,
sizeof
(
GLOBAL32_INTERN
));
pintern
=
HeapAlloc
(
GetProcessH
eap
()
,
0
,
sizeof
(
GLOBAL32_INTERN
));
if
(
!
pintern
)
return
0
;
if
(
size
)
{
if
(
!
(
palloc
=
HeapAlloc
(
h
eap
,
hpflags
,
size
+
sizeof
(
HGLOBAL
))))
{
HeapFree
(
h
eap
,
0
,
pintern
);
if
(
!
(
palloc
=
HeapAlloc
(
GetProcessH
eap
()
,
hpflags
,
size
+
sizeof
(
HGLOBAL
))))
{
HeapFree
(
GetProcessH
eap
()
,
0
,
pintern
);
return
0
;
}
*
(
HGLOBAL
*
)
palloc
=
INTERN_TO_HANDLE
(
pintern
);
...
...
@@ -1163,7 +1130,6 @@ HGLOBAL WINAPI GlobalHandle(
LPCVOID
pmem
/* [in] Pointer to global memory block */
)
{
HGLOBAL
handle
;
HANDLE
heap
;
PGLOBAL32_INTERN
maybe_intern
;
LPCVOID
test
;
...
...
@@ -1181,8 +1147,7 @@ HGLOBAL WINAPI GlobalHandle(
/* GlobalAlloc with GMEM_MOVEABLE then magic test in HeapValidate */
/* will fail. */
if
(
ISPOINTER
(
pmem
))
{
heap
=
GLOBAL_GetHeap
(
(
HGLOBAL
)
pmem
);
if
(
HeapValidate
(
heap
,
0
,
pmem
))
{
if
(
HeapValidate
(
GetProcessHeap
(),
0
,
pmem
))
{
handle
=
(
HGLOBAL
)
pmem
;
/* valid fixed block */
break
;
}
...
...
@@ -1191,12 +1156,11 @@ HGLOBAL WINAPI GlobalHandle(
handle
=
(
HGLOBAL
)
pmem
;
/* Now test handle either passed in or retrieved from pointer */
heap
=
GLOBAL_GetHeap
(
handle
);
maybe_intern
=
HANDLE_TO_INTERN
(
handle
);
if
(
maybe_intern
->
Magic
==
MAGIC_GLOBAL_USED
)
{
test
=
maybe_intern
->
Pointer
;
if
(
HeapValidate
(
h
eap
,
0
,
((
HGLOBAL
*
)
test
)
-
1
)
&&
/* obj(-handle) valid arena? */
HeapValidate
(
h
eap
,
0
,
maybe_intern
))
/* intern valid arena? */
if
(
HeapValidate
(
GetProcessH
eap
()
,
0
,
((
HGLOBAL
*
)
test
)
-
1
)
&&
/* obj(-handle) valid arena? */
HeapValidate
(
GetProcessH
eap
()
,
0
,
maybe_intern
))
/* intern valid arena? */
break
;
/* valid moveable block */
}
handle
=
0
;
...
...
@@ -1227,7 +1191,6 @@ HGLOBAL WINAPI GlobalReAlloc(
LPVOID
palloc
;
HGLOBAL
hnew
;
PGLOBAL32_INTERN
pintern
;
HANDLE
heap
=
GLOBAL_GetHeap
(
hmem
);
DWORD
heap_flags
=
(
flags
&
GMEM_ZEROINIT
)
?
HEAP_ZERO_MEMORY
:
0
;
hnew
=
0
;
...
...
@@ -1245,7 +1208,7 @@ HGLOBAL WINAPI GlobalReAlloc(
SetLastError
(
ERROR_NOACCESS
);
return
0
;
}
size
=
HeapSize
(
h
eap
,
0
,
(
LPVOID
)
hmem
);
size
=
HeapSize
(
GetProcessH
eap
()
,
0
,
(
LPVOID
)
hmem
);
hnew
=
GlobalAlloc
(
flags
,
size
);
palloc
=
GlobalLock
(
hnew
);
memcpy
(
palloc
,
(
LPVOID
)
hmem
,
size
);
...
...
@@ -1270,7 +1233,7 @@ HGLOBAL WINAPI GlobalReAlloc(
if
(
ISPOINTER
(
hmem
))
{
/* reallocate fixed memory */
hnew
=
(
HGLOBAL
)
HeapReAlloc
(
h
eap
,
heap_flags
,
(
LPVOID
)
hmem
,
size
);
hnew
=
(
HGLOBAL
)
HeapReAlloc
(
GetProcessH
eap
()
,
heap_flags
,
(
LPVOID
)
hmem
,
size
);
}
else
{
...
...
@@ -1290,7 +1253,7 @@ HGLOBAL WINAPI GlobalReAlloc(
hnew
=
hmem
;
if
(
pintern
->
Pointer
)
{
if
((
palloc
=
HeapReAlloc
(
h
eap
,
heap_flags
,
if
((
palloc
=
HeapReAlloc
(
GetProcessH
eap
()
,
heap_flags
,
(
char
*
)
pintern
->
Pointer
-
sizeof
(
HGLOBAL
),
size
+
sizeof
(
HGLOBAL
)))
==
NULL
)
return
0
;
/* Block still valid */
...
...
@@ -1298,7 +1261,7 @@ HGLOBAL WINAPI GlobalReAlloc(
}
else
{
if
((
palloc
=
HeapAlloc
(
h
eap
,
heap_flags
,
size
+
sizeof
(
HGLOBAL
)))
if
((
palloc
=
HeapAlloc
(
GetProcessH
eap
()
,
heap_flags
,
size
+
sizeof
(
HGLOBAL
)))
==
NULL
)
return
0
;
*
(
HGLOBAL
*
)
palloc
=
hmem
;
...
...
@@ -1309,7 +1272,7 @@ HGLOBAL WINAPI GlobalReAlloc(
{
if
(
pintern
->
Pointer
)
{
HeapFree
(
h
eap
,
0
,
(
char
*
)
pintern
->
Pointer
-
sizeof
(
HGLOBAL
));
HeapFree
(
GetProcessH
eap
()
,
0
,
(
char
*
)
pintern
->
Pointer
-
sizeof
(
HGLOBAL
));
pintern
->
Pointer
=
NULL
;
}
}
...
...
@@ -1331,11 +1294,10 @@ HGLOBAL WINAPI GlobalFree(
)
{
PGLOBAL32_INTERN
pintern
;
HGLOBAL
hreturned
=
0
;
HANDLE
heap
=
GLOBAL_GetHeap
(
hmem
);
if
(
ISPOINTER
(
hmem
))
/* POINTER */
{
if
(
!
HeapFree
(
h
eap
,
0
,
(
LPVOID
)
hmem
))
hmem
=
0
;
if
(
!
HeapFree
(
GetProcessH
eap
()
,
0
,
(
LPVOID
)
hmem
))
hmem
=
0
;
}
else
/* HANDLE */
{
...
...
@@ -1351,10 +1313,9 @@ HGLOBAL WINAPI GlobalFree(
/* SetLastError(ERROR_INVALID_HANDLE); */
if
(
pintern
->
Pointer
)
if
(
!
HeapFree
(
heap
,
0
,
(
char
*
)(
pintern
->
Pointer
)
-
sizeof
(
HGLOBAL
)))
if
(
!
HeapFree
(
GetProcessHeap
(),
0
,
(
char
*
)(
pintern
->
Pointer
)
-
sizeof
(
HGLOBAL
)))
hreturned
=
hmem
;
if
(
!
HeapFree
(
h
eap
,
0
,
pintern
))
if
(
!
HeapFree
(
GetProcessH
eap
()
,
0
,
pintern
))
hreturned
=
hmem
;
}
/* HeapUnlock(heap); */
...
...
@@ -1374,11 +1335,10 @@ DWORD WINAPI GlobalSize(
)
{
DWORD
retval
;
PGLOBAL32_INTERN
pintern
;
HANDLE
heap
=
GLOBAL_GetHeap
(
hmem
);
if
(
ISPOINTER
(
hmem
))
{
retval
=
HeapSize
(
h
eap
,
0
,
(
LPVOID
)
hmem
);
retval
=
HeapSize
(
GetProcessH
eap
()
,
0
,
(
LPVOID
)
hmem
);
}
else
{
...
...
@@ -1389,7 +1349,7 @@ DWORD WINAPI GlobalSize(
{
if
(
!
pintern
->
Pointer
)
/* handle case of GlobalAlloc( ??,0) */
return
0
;
retval
=
HeapSize
(
h
eap
,
0
,
retval
=
HeapSize
(
GetProcessH
eap
()
,
0
,
(
char
*
)(
pintern
->
Pointer
)
-
sizeof
(
HGLOBAL
))
-
4
;
if
(
retval
==
0xffffffff
-
4
)
retval
=
0
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment