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
17da2665
Commit
17da2665
authored
Dec 04, 2023
by
Alex Henrie
Committed by
Alexandre Julliard
Dec 04, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3dx9: Use CRT allocation functions.
parent
3b3a65ad
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
198 additions
and
232 deletions
+198
-232
animation.c
dlls/d3dx9_36/animation.c
+7
-10
core.c
dlls/d3dx9_36/core.c
+5
-5
d3dx9_private.h
dlls/d3dx9_36/d3dx9_private.h
+0
-1
effect.c
dlls/d3dx9_36/effect.c
+0
-0
font.c
dlls/d3dx9_36/font.c
+34
-34
line.c
dlls/d3dx9_36/line.c
+2
-2
math.c
dlls/d3dx9_36/math.c
+7
-7
mesh.c
dlls/d3dx9_36/mesh.c
+0
-0
preshader.c
dlls/d3dx9_36/preshader.c
+14
-16
render.c
dlls/d3dx9_36/render.c
+8
-9
shader.c
dlls/d3dx9_36/shader.c
+36
-37
skin.c
dlls/d3dx9_36/skin.c
+16
-19
sprite.c
dlls/d3dx9_36/sprite.c
+10
-14
surface.c
dlls/d3dx9_36/surface.c
+25
-24
texture.c
dlls/d3dx9_36/texture.c
+14
-14
volume.c
dlls/d3dx9_36/volume.c
+2
-2
xfile.c
dlls/d3dx9_36/xfile.c
+18
-38
No files found.
dlls/d3dx9_36/animation.c
View file @
17da2665
...
...
@@ -75,7 +75,7 @@ static ULONG WINAPI d3dx9_animation_controller_Release(ID3DXAnimationController
if
(
!
refcount
)
{
HeapFree
(
GetProcessHeap
(),
0
,
animation
);
free
(
animation
);
}
return
refcount
;
...
...
@@ -452,7 +452,7 @@ HRESULT WINAPI D3DXCreateAnimationController(UINT max_outputs, UINT max_sets,
if
(
!
max_outputs
||
!
max_sets
||
!
max_tracks
||
!
max_events
||
!
controller
)
return
D3D_OK
;
object
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
object
));
object
=
calloc
(
1
,
sizeof
(
*
object
));
if
(
!
object
)
return
E_OUTOFMEMORY
;
...
...
@@ -524,8 +524,8 @@ static ULONG WINAPI d3dx9_keyframed_animation_Release(ID3DXKeyframedAnimationSet
if
(
!
refcount
)
{
heap_
free
((
char
*
)
set
->
name
);
heap_
free
(
set
);
free
((
char
*
)
set
->
name
);
free
(
set
);
}
return
refcount
;
...
...
@@ -860,7 +860,6 @@ HRESULT WINAPI D3DXCreateKeyframedAnimationSet(const char *name, double ticks_pe
const
D3DXKEY_CALLBACK
*
callback_keys
,
ID3DXKeyframedAnimationSet
**
animation_set
)
{
struct
d3dx9_keyframed_animation_set
*
object
;
char
*
string
;
TRACE
(
"name %s, ticks_per_second %.16e, playback_type %u, animation_count %u, "
"callback_key_count %u, callback_keys %p, animation_set %p.
\n
"
,
...
...
@@ -870,18 +869,16 @@ HRESULT WINAPI D3DXCreateKeyframedAnimationSet(const char *name, double ticks_pe
if
(
!
animation_count
)
return
D3DERR_INVALIDCALL
;
if
(
!
(
object
=
heap_alloc
(
sizeof
(
*
object
))))
if
(
!
(
object
=
calloc
(
1
,
sizeof
(
*
object
))))
return
E_OUTOFMEMORY
;
object
->
ID3DXKeyframedAnimationSet_iface
.
lpVtbl
=
&
d3dx9_keyframed_animation_vtbl
;
object
->
ref
=
1
;
if
(
!
(
string
=
heap_alloc
(
strlen
(
name
)
+
1
)))
if
(
!
(
object
->
name
=
strdup
(
name
)))
{
heap_
free
(
object
);
free
(
object
);
return
E_OUTOFMEMORY
;
}
strcpy
(
string
,
name
);
object
->
name
=
string
;
object
->
ticks_per_second
=
ticks_per_second
;
object
->
playback_type
=
playback_type
;
object
->
animation_count
=
animation_count
;
...
...
dlls/d3dx9_36/core.c
View file @
17da2665
...
...
@@ -72,8 +72,8 @@ static ULONG WINAPI ID3DXBufferImpl_Release(ID3DXBuffer *iface)
if
(
ref
==
0
)
{
HeapFree
(
GetProcessHeap
(),
0
,
This
->
buffer
);
HeapFree
(
GetProcessHeap
(),
0
,
This
);
free
(
This
->
buffer
);
free
(
This
);
}
return
ref
;
...
...
@@ -114,7 +114,7 @@ static HRESULT d3dx9_buffer_init(struct ID3DXBufferImpl *buffer, DWORD size)
buffer
->
ref
=
1
;
buffer
->
size
=
size
;
buffer
->
buffer
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
size
);
buffer
->
buffer
=
calloc
(
1
,
size
);
if
(
!
buffer
->
buffer
)
{
ERR
(
"Failed to allocate buffer memory
\n
"
);
...
...
@@ -137,7 +137,7 @@ HRESULT WINAPI D3DXCreateBuffer(DWORD size, ID3DXBuffer **buffer)
return
D3DERR_INVALIDCALL
;
}
object
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
*
object
));
object
=
calloc
(
1
,
sizeof
(
*
object
));
if
(
!
object
)
return
E_OUTOFMEMORY
;
...
...
@@ -145,7 +145,7 @@ HRESULT WINAPI D3DXCreateBuffer(DWORD size, ID3DXBuffer **buffer)
if
(
FAILED
(
hr
))
{
WARN
(
"Failed to initialize buffer, hr %#lx.
\n
"
,
hr
);
HeapFree
(
GetProcessHeap
(),
0
,
object
);
free
(
object
);
return
hr
;
}
...
...
dlls/d3dx9_36/d3dx9_private.h
View file @
17da2665
...
...
@@ -24,7 +24,6 @@
#include <stdint.h>
#include "wine/debug.h"
#include "wine/heap.h"
#include "wine/rbtree.h"
#define COBJMACROS
...
...
dlls/d3dx9_36/effect.c
View file @
17da2665
This diff is collapsed.
Click to expand it.
dlls/d3dx9_36/font.c
View file @
17da2665
...
...
@@ -66,7 +66,7 @@ static void glyph_rb_free(struct wine_rb_entry *entry, void *context)
{
struct
d3dx_glyph
*
glyph
=
WINE_RB_ENTRY_VALUE
(
entry
,
struct
d3dx_glyph
,
entry
);
heap_
free
(
glyph
);
free
(
glyph
);
}
static
inline
struct
d3dx_font
*
impl_from_ID3DXFont
(
ID3DXFont
*
iface
)
...
...
@@ -114,14 +114,14 @@ static ULONG WINAPI ID3DXFontImpl_Release(ID3DXFont *iface)
for
(
i
=
0
;
i
<
font
->
texture_count
;
++
i
)
IDirect3DTexture9_Release
(
font
->
textures
[
i
]);
heap_
free
(
font
->
textures
);
free
(
font
->
textures
);
wine_rb_destroy
(
&
font
->
glyph_tree
,
glyph_rb_free
,
NULL
);
DeleteObject
(
font
->
hfont
);
DeleteDC
(
font
->
hdc
);
IDirect3DDevice9_Release
(
font
->
device
);
heap_
free
(
font
);
free
(
font
);
}
return
ref
;
}
...
...
@@ -233,14 +233,14 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadCharacters(ID3DXFont *iface, UINT fir
return
D3D_OK
;
count
=
last
-
first
+
1
;
indices
=
heap_alloc
(
count
*
sizeof
(
*
indices
));
indices
=
calloc
(
count
,
sizeof
(
*
indices
));
if
(
!
indices
)
return
E_OUTOFMEMORY
;
chars
=
heap_alloc
(
count
*
sizeof
(
*
chars
));
chars
=
calloc
(
count
,
sizeof
(
*
chars
));
if
(
!
chars
)
{
heap_
free
(
indices
);
free
(
indices
);
return
E_OUTOFMEMORY
;
}
...
...
@@ -262,8 +262,8 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadCharacters(ID3DXFont *iface, UINT fir
}
ID3DXFont_PreloadGlyphs
(
iface
,
start
,
end
);
heap_
free
(
chars
);
heap_
free
(
indices
);
free
(
chars
);
free
(
indices
);
return
D3D_OK
;
}
...
...
@@ -322,7 +322,7 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadGlyphs(ID3DXFont *iface, UINT first,
if
(
wine_rb_get
(
&
font
->
glyph_tree
,
ULongToPtr
(
glyph
)))
continue
;
current_glyph
=
heap_
alloc
(
sizeof
(
*
current_glyph
));
current_glyph
=
m
alloc
(
sizeof
(
*
current_glyph
));
if
(
!
current_glyph
)
{
if
(
mapped
)
...
...
@@ -343,7 +343,7 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadGlyphs(ID3DXFont *iface, UINT first,
if
(
!
size
)
continue
;
buffer
=
heap_
alloc
(
size
);
buffer
=
m
alloc
(
size
);
if
(
!
buffer
)
{
if
(
mapped
)
...
...
@@ -361,10 +361,10 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadGlyphs(ID3DXFont *iface, UINT first,
if
(
mapped
)
IDirect3DTexture9_UnlockRect
(
current_texture
,
0
);
mapped
=
FALSE
;
new_textures
=
heap_
realloc
(
font
->
textures
,
new_texture_count
*
sizeof
(
*
new_textures
));
new_textures
=
realloc
(
font
->
textures
,
new_texture_count
*
sizeof
(
*
new_textures
));
if
(
!
new_textures
)
{
heap_
free
(
buffer
);
free
(
buffer
);
return
E_OUTOFMEMORY
;
}
font
->
textures
=
new_textures
;
...
...
@@ -373,7 +373,7 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadGlyphs(ID3DXFont *iface, UINT first,
font
->
texture_size
,
0
,
0
,
D3DFMT_A8R8G8B8
,
D3DPOOL_MANAGED
,
&
font
->
textures
[
font
->
texture_count
],
NULL
)))
{
heap_
free
(
buffer
);
free
(
buffer
);
return
hr
;
}
...
...
@@ -385,7 +385,7 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadGlyphs(ID3DXFont *iface, UINT first,
{
if
(
FAILED
(
hr
=
IDirect3DTexture9_LockRect
(
current_texture
,
0
,
&
lockrect
,
NULL
,
0
)))
{
heap_
free
(
buffer
);
free
(
buffer
);
return
hr
;
}
mapped
=
TRUE
;
...
...
@@ -411,7 +411,7 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadGlyphs(ID3DXFont *iface, UINT first,
+
current_glyph
->
black_box
.
left
+
x
]
=
(
buffer
[
y
*
stride
+
x
]
*
255
/
64
<<
24
)
|
0x00ffffffu
;
heap_
free
(
buffer
);
free
(
buffer
);
++
font
->
texture_pos
;
}
if
(
mapped
)
...
...
@@ -436,7 +436,7 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadTextA(ID3DXFont *iface, const char *s
countW
=
MultiByteToWideChar
(
CP_ACP
,
0
,
string
,
count
<
0
?
-
1
:
count
,
NULL
,
0
);
wstr
=
heap_
alloc
(
countW
*
sizeof
(
*
wstr
));
wstr
=
m
alloc
(
countW
*
sizeof
(
*
wstr
));
if
(
!
wstr
)
return
E_OUTOFMEMORY
;
...
...
@@ -444,7 +444,7 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadTextA(ID3DXFont *iface, const char *s
hr
=
ID3DXFont_PreloadTextW
(
iface
,
wstr
,
count
<
0
?
countW
-
1
:
countW
);
heap_
free
(
wstr
);
free
(
wstr
);
return
hr
;
}
...
...
@@ -466,7 +466,7 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadTextW(ID3DXFont *iface, const WCHAR *
if
(
count
<
0
)
count
=
lstrlenW
(
string
);
indices
=
heap_
alloc
(
count
*
sizeof
(
*
indices
));
indices
=
m
alloc
(
count
*
sizeof
(
*
indices
));
if
(
!
indices
)
return
E_OUTOFMEMORY
;
...
...
@@ -475,7 +475,7 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadTextW(ID3DXFont *iface, const WCHAR *
for
(
i
=
0
;
i
<
count
;
++
i
)
ID3DXFont_PreloadGlyphs
(
iface
,
indices
[
i
],
indices
[
i
]);
heap_
free
(
indices
);
free
(
indices
);
return
D3D_OK
;
}
...
...
@@ -497,7 +497,7 @@ static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, ID3DXSprite *sprite,
if
(
!
countW
)
return
0
;
wstr
=
heap_alloc_zero
(
countW
*
sizeof
(
*
wstr
));
wstr
=
calloc
(
countW
,
sizeof
(
*
wstr
));
if
(
!
wstr
)
return
0
;
...
...
@@ -506,7 +506,7 @@ static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, ID3DXSprite *sprite,
ret
=
ID3DXFont_DrawTextW
(
iface
,
sprite
,
wstr
,
count
<
0
?
countW
-
1
:
countW
,
rect
,
format
,
color
);
heap_
free
(
wstr
);
free
(
wstr
);
return
ret
;
}
...
...
@@ -520,7 +520,7 @@ static void word_break(HDC hdc, const WCHAR *str, unsigned int *str_len,
*
chars_used
=
0
;
sla
=
heap_
alloc
(
*
str_len
*
sizeof
(
*
sla
));
sla
=
m
alloc
(
*
str_len
*
sizeof
(
*
sla
));
if
(
!
sla
)
return
;
...
...
@@ -549,7 +549,7 @@ static void word_break(HDC hdc, const WCHAR *str, unsigned int *str_len,
/* Remeasure the string */
GetTextExtentExPointW
(
hdc
,
str
,
*
str_len
,
0
,
NULL
,
NULL
,
size
);
heap_
free
(
sla
);
free
(
sla
);
}
static
const
WCHAR
*
read_line
(
HDC
hdc
,
const
WCHAR
*
str
,
unsigned
int
*
count
,
...
...
@@ -675,7 +675,7 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite,
if
(
format
&
DT_SINGLELINE
)
format
&=
~
DT_WORDBREAK
;
line
=
heap_
alloc
(
count
*
sizeof
(
*
line
));
line
=
m
alloc
(
count
*
sizeof
(
*
line
));
if
(
!
line
)
return
0
;
...
...
@@ -731,14 +731,14 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite,
memset
(
&
results
,
0
,
sizeof
(
results
));
results
.
nGlyphs
=
line_len
;
results
.
lpCaretPos
=
heap_
alloc
(
line_len
*
sizeof
(
*
results
.
lpCaretPos
));
results
.
lpCaretPos
=
m
alloc
(
line_len
*
sizeof
(
*
results
.
lpCaretPos
));
if
(
!
results
.
lpCaretPos
)
goto
cleanup
;
results
.
lpGlyphs
=
heap_
alloc
(
line_len
*
sizeof
(
*
results
.
lpGlyphs
));
results
.
lpGlyphs
=
m
alloc
(
line_len
*
sizeof
(
*
results
.
lpGlyphs
));
if
(
!
results
.
lpGlyphs
)
{
heap_
free
(
results
.
lpCaretPos
);
free
(
results
.
lpCaretPos
);
goto
cleanup
;
}
...
...
@@ -779,8 +779,8 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite,
IDirect3DTexture9_Release
(
texture
);
}
heap_
free
(
results
.
lpCaretPos
);
heap_
free
(
results
.
lpGlyphs
);
free
(
results
.
lpCaretPos
);
free
(
results
.
lpGlyphs
);
y
+=
lh
;
if
(
!
(
DT_NOCLIP
&
format
)
&&
(
y
>
rect
->
bottom
))
...
...
@@ -796,7 +796,7 @@ cleanup:
ID3DXSprite_Release
(
target
);
}
heap_
free
(
line
);
free
(
line
);
return
ret
;
}
...
...
@@ -925,7 +925,7 @@ HRESULT WINAPI D3DXCreateFontIndirectW(IDirect3DDevice9 *device, const D3DXFONT_
}
IDirect3D9_Release
(
d3d
);
object
=
heap_alloc_zero
(
sizeof
(
*
object
));
object
=
calloc
(
1
,
sizeof
(
*
object
));
if
(
!
object
)
{
*
font
=
NULL
;
...
...
@@ -939,7 +939,7 @@ HRESULT WINAPI D3DXCreateFontIndirectW(IDirect3DDevice9 *device, const D3DXFONT_
object
->
hdc
=
CreateCompatibleDC
(
NULL
);
if
(
!
object
->
hdc
)
{
heap_
free
(
object
);
free
(
object
);
return
D3DXERR_INVALIDDATA
;
}
...
...
@@ -948,7 +948,7 @@ HRESULT WINAPI D3DXCreateFontIndirectW(IDirect3DDevice9 *device, const D3DXFONT_
if
(
!
object
->
hfont
)
{
DeleteDC
(
object
->
hdc
);
heap_
free
(
object
);
free
(
object
);
return
D3DXERR_INVALIDDATA
;
}
SelectObject
(
object
->
hdc
,
object
->
hfont
);
...
...
@@ -959,7 +959,7 @@ HRESULT WINAPI D3DXCreateFontIndirectW(IDirect3DDevice9 *device, const D3DXFONT_
{
DeleteObject
(
object
->
hfont
);
DeleteDC
(
object
->
hdc
);
heap_
free
(
object
);
free
(
object
);
return
D3DXERR_INVALIDDATA
;
}
...
...
dlls/d3dx9_36/line.c
View file @
17da2665
...
...
@@ -75,7 +75,7 @@ static ULONG WINAPI d3dx9_line_Release(ID3DXLine *iface)
if
(
!
refcount
)
{
IDirect3DDevice9_Release
(
line
->
device
);
HeapFree
(
GetProcessHeap
(),
0
,
line
);
free
(
line
);
}
return
refcount
;
...
...
@@ -309,7 +309,7 @@ HRESULT WINAPI D3DXCreateLine(struct IDirect3DDevice9 *device, struct ID3DXLine
if
(
!
device
||
!
line
)
return
D3DERR_INVALIDCALL
;
if
(
!
(
object
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
*
object
))))
if
(
!
(
object
=
calloc
(
1
,
sizeof
(
*
object
))))
return
E_OUTOFMEMORY
;
object
->
ID3DXLine_iface
.
lpVtbl
=
&
d3dx9_line_vtbl
;
...
...
dlls/d3dx9_36/math.c
View file @
17da2665
...
...
@@ -928,8 +928,8 @@ static ULONG WINAPI ID3DXMatrixStackImpl_Release(ID3DXMatrixStack *iface)
TRACE
(
"%p decreasing refcount to %lu.
\n
"
,
iface
,
refcount
);
if
(
!
refcount
)
{
HeapFree
(
GetProcessHeap
(),
0
,
stack
->
stack
);
HeapFree
(
GetProcessHeap
(),
0
,
stack
);
free
(
stack
->
stack
);
free
(
stack
);
}
return
refcount
;
}
...
...
@@ -1002,7 +1002,7 @@ static HRESULT WINAPI ID3DXMatrixStackImpl_Pop(ID3DXMatrixStack *iface)
D3DXMATRIX
*
new_stack
;
new_size
=
This
->
stack_size
/
2
;
new_stack
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
This
->
stack
,
new_size
*
sizeof
(
*
new_stack
));
new_stack
=
realloc
(
This
->
stack
,
new_size
*
sizeof
(
*
new_stack
));
if
(
new_stack
)
{
This
->
stack_size
=
new_size
;
...
...
@@ -1029,7 +1029,7 @@ static HRESULT WINAPI ID3DXMatrixStackImpl_Push(ID3DXMatrixStack *iface)
if
(
This
->
stack_size
>
UINT_MAX
/
2
)
return
E_OUTOFMEMORY
;
new_size
=
This
->
stack_size
*
2
;
new_stack
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
This
->
stack
,
new_size
*
sizeof
(
*
new_stack
));
new_stack
=
realloc
(
This
->
stack
,
new_size
*
sizeof
(
*
new_stack
));
if
(
!
new_stack
)
return
E_OUTOFMEMORY
;
This
->
stack_size
=
new_size
;
...
...
@@ -1174,7 +1174,7 @@ HRESULT WINAPI D3DXCreateMatrixStack(DWORD flags, ID3DXMatrixStack **stack)
TRACE
(
"flags %#lx, stack %p.
\n
"
,
flags
,
stack
);
if
(
!
(
object
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
*
object
))))
if
(
!
(
object
=
calloc
(
1
,
sizeof
(
*
object
))))
{
*
stack
=
NULL
;
return
E_OUTOFMEMORY
;
...
...
@@ -1182,9 +1182,9 @@ HRESULT WINAPI D3DXCreateMatrixStack(DWORD flags, ID3DXMatrixStack **stack)
object
->
ID3DXMatrixStack_iface
.
lpVtbl
=
&
ID3DXMatrixStack_Vtbl
;
object
->
ref
=
1
;
if
(
!
(
object
->
stack
=
HeapAlloc
(
GetProcessHeap
(),
0
,
INITIAL_STACK_SIZE
*
sizeof
(
*
object
->
stack
))))
if
(
!
(
object
->
stack
=
malloc
(
INITIAL_STACK_SIZE
*
sizeof
(
*
object
->
stack
))))
{
HeapFree
(
GetProcessHeap
(),
0
,
object
);
free
(
object
);
*
stack
=
NULL
;
return
E_OUTOFMEMORY
;
}
...
...
dlls/d3dx9_36/mesh.c
View file @
17da2665
This diff is collapsed.
Click to expand it.
dlls/d3dx9_36/preshader.c
View file @
17da2665
...
...
@@ -308,7 +308,7 @@ static HRESULT regstore_alloc_table(struct d3dx_regstore *rs, unsigned int table
size
=
get_offset_reg
(
table
,
rs
->
table_sizes
[
table
])
*
table_info
[
table
].
component_size
;
if
(
size
)
{
rs
->
tables
[
table
]
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
size
);
rs
->
tables
[
table
]
=
calloc
(
1
,
size
);
if
(
!
rs
->
tables
[
table
])
return
E_OUTOFMEMORY
;
}
...
...
@@ -321,7 +321,7 @@ static void regstore_free_tables(struct d3dx_regstore *rs)
for
(
i
=
0
;
i
<
PRES_REGTAB_COUNT
;
++
i
)
{
HeapFree
(
GetProcessHeap
(),
0
,
rs
->
tables
[
i
]);
free
(
rs
->
tables
[
i
]);
}
}
...
...
@@ -593,7 +593,7 @@ static HRESULT append_const_set(struct d3dx_const_tab *const_tab, struct d3dx_co
if
(
!
const_tab
->
const_set_size
)
{
new_size
=
INITIAL_CONST_SET_SIZE
;
new_alloc
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
const_tab
->
const_set
)
*
new_size
);
new_alloc
=
malloc
(
sizeof
(
*
const_tab
->
const_set
)
*
new_size
);
if
(
!
new_alloc
)
{
ERR
(
"Out of memory.
\n
"
);
...
...
@@ -603,8 +603,7 @@ static HRESULT append_const_set(struct d3dx_const_tab *const_tab, struct d3dx_co
else
{
new_size
=
const_tab
->
const_set_size
*
2
;
new_alloc
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
const_tab
->
const_set
,
sizeof
(
*
const_tab
->
const_set
)
*
new_size
);
new_alloc
=
realloc
(
const_tab
->
const_set
,
sizeof
(
*
const_tab
->
const_set
)
*
new_size
);
if
(
!
new_alloc
)
{
ERR
(
"Out of memory.
\n
"
);
...
...
@@ -875,8 +874,8 @@ static HRESULT get_constants_desc(unsigned int *byte_code, struct d3dx_const_tab
goto
cleanup
;
}
out
->
inputs
=
cdesc
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
cdesc
)
*
desc
.
Constants
);
out
->
inputs_param
=
inputs_param
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
inputs_param
)
*
desc
.
Constants
);
out
->
inputs
=
cdesc
=
malloc
(
sizeof
(
*
cdesc
)
*
desc
.
Constants
);
out
->
inputs_param
=
inputs_param
=
malloc
(
sizeof
(
*
inputs_param
)
*
desc
.
Constants
);
if
(
!
cdesc
||
!
inputs_param
)
{
hr
=
E_OUTOFMEMORY
;
...
...
@@ -980,8 +979,7 @@ static HRESULT get_constants_desc(unsigned int *byte_code, struct d3dx_const_tab
}
}
new_alloc
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
out
->
const_set
,
sizeof
(
*
out
->
const_set
)
*
out
->
const_set_count
);
new_alloc
=
realloc
(
out
->
const_set
,
sizeof
(
*
out
->
const_set
)
*
out
->
const_set_count
);
if
(
new_alloc
)
{
out
->
const_set
=
new_alloc
;
...
...
@@ -1158,7 +1156,7 @@ static HRESULT parse_preshader(struct d3dx_preshader *pres, unsigned int *ptr, u
return
D3DXERR_INVALIDDATA
;
}
TRACE
(
"%u instructions.
\n
"
,
pres
->
ins_count
);
pres
->
ins
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
*
pres
->
ins
)
*
pres
->
ins_count
);
pres
->
ins
=
calloc
(
pres
->
ins_count
,
sizeof
(
*
pres
->
ins
)
);
if
(
!
pres
->
ins
)
return
E_OUTOFMEMORY
;
for
(
i
=
0
;
i
<
pres
->
ins_count
;
++
i
)
...
...
@@ -1252,7 +1250,7 @@ HRESULT d3dx_create_param_eval(struct d3dx_parameters_store *parameters, void *b
return
D3D_OK
;
}
peval
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
*
peval
));
peval
=
calloc
(
1
,
sizeof
(
*
peval
));
if
(
!
peval
)
{
ret
=
E_OUTOFMEMORY
;
...
...
@@ -1343,14 +1341,14 @@ err_out:
static
void
d3dx_free_const_tab
(
struct
d3dx_const_tab
*
ctab
)
{
HeapFree
(
GetProcessHeap
(),
0
,
ctab
->
inputs
);
HeapFree
(
GetProcessHeap
(),
0
,
ctab
->
inputs_param
);
HeapFree
(
GetProcessHeap
(),
0
,
ctab
->
const_set
);
free
(
ctab
->
inputs
);
free
(
ctab
->
inputs_param
);
free
(
ctab
->
const_set
);
}
static
void
d3dx_free_preshader
(
struct
d3dx_preshader
*
pres
)
{
HeapFree
(
GetProcessHeap
(),
0
,
pres
->
ins
);
free
(
pres
->
ins
);
regstore_free_tables
(
&
pres
->
regs
);
d3dx_free_const_tab
(
&
pres
->
inputs
);
...
...
@@ -1365,7 +1363,7 @@ void d3dx_free_param_eval(struct d3dx_param_eval *peval)
d3dx_free_preshader
(
&
peval
->
pres
);
d3dx_free_const_tab
(
&
peval
->
shader_inputs
);
HeapFree
(
GetProcessHeap
(),
0
,
peval
);
free
(
peval
);
}
static
void
pres_int_from_float
(
void
*
out
,
const
void
*
in
,
unsigned
int
count
)
...
...
dlls/d3dx9_36/render.c
View file @
17da2665
...
...
@@ -40,8 +40,7 @@ static HRESULT device_state_init(IDirect3DDevice9 *device, struct device_state *
if
(
FAILED
(
hr
))
return
hr
;
state
->
num_render_targets
=
caps
.
NumSimultaneousRTs
;
state
->
render_targets
=
HeapAlloc
(
GetProcessHeap
(),
0
,
state
->
num_render_targets
*
sizeof
(
IDirect3DSurface9
*
));
state
->
render_targets
=
malloc
(
state
->
num_render_targets
*
sizeof
(
IDirect3DSurface9
*
));
if
(
!
state
->
render_targets
)
return
E_OUTOFMEMORY
;
...
...
@@ -100,7 +99,7 @@ static void device_state_release(struct device_state *state)
IDirect3DSurface9_Release
(
state
->
render_targets
[
i
]);
}
HeapFree
(
GetProcessHeap
(),
0
,
state
->
render_targets
);
free
(
state
->
render_targets
);
if
(
state
->
depth_stencil
)
IDirect3DSurface9_Release
(
state
->
depth_stencil
);
}
...
...
@@ -174,7 +173,7 @@ static ULONG WINAPI D3DXRenderToSurface_Release(ID3DXRenderToSurface *iface)
IDirect3DDevice9_Release
(
render
->
device
);
HeapFree
(
GetProcessHeap
(),
0
,
render
);
free
(
render
);
}
return
ref
;
...
...
@@ -386,7 +385,7 @@ HRESULT WINAPI D3DXCreateRenderToSurface(IDirect3DDevice9 *device,
if
(
!
device
||
!
out
)
return
D3DERR_INVALIDCALL
;
render
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
struct
render_to_surface
));
render
=
malloc
(
sizeof
(
struct
render_to_surface
));
if
(
!
render
)
return
E_OUTOFMEMORY
;
render
->
ID3DXRenderToSurface_iface
.
lpVtbl
=
&
render_to_surface_vtbl
;
...
...
@@ -405,7 +404,7 @@ HRESULT WINAPI D3DXCreateRenderToSurface(IDirect3DDevice9 *device,
hr
=
device_state_init
(
device
,
&
render
->
previous_state
);
if
(
FAILED
(
hr
))
{
HeapFree
(
GetProcessHeap
(),
0
,
render
);
free
(
render
);
return
hr
;
}
...
...
@@ -513,7 +512,7 @@ static ULONG WINAPI D3DXRenderToEnvMap_Release(ID3DXRenderToEnvMap *iface)
IDirect3DDevice9_Release
(
render
->
device
);
HeapFree
(
GetProcessHeap
(),
0
,
render
);
free
(
render
);
}
return
ref
;
...
...
@@ -764,7 +763,7 @@ HRESULT WINAPI D3DXCreateRenderToEnvMap(IDirect3DDevice9 *device,
D3DUSAGE_RENDERTARGET
,
&
format
,
D3DPOOL_DEFAULT
);
if
(
FAILED
(
hr
))
return
hr
;
render
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
struct
render_to_envmap
));
render
=
malloc
(
sizeof
(
*
render
));
if
(
!
render
)
return
E_OUTOFMEMORY
;
render
->
ID3DXRenderToEnvMap_iface
.
lpVtbl
=
&
render_to_envmap_vtbl
;
...
...
@@ -784,7 +783,7 @@ HRESULT WINAPI D3DXCreateRenderToEnvMap(IDirect3DDevice9 *device,
hr
=
device_state_init
(
device
,
&
render
->
previous_device_state
);
if
(
FAILED
(
hr
))
{
HeapFree
(
GetProcessHeap
(),
0
,
render
);
free
(
render
);
return
hr
;
}
...
...
dlls/d3dx9_36/shader.c
View file @
17da2665
This diff is collapsed.
Click to expand it.
dlls/d3dx9_36/skin.c
View file @
17da2665
...
...
@@ -88,12 +88,12 @@ static ULONG WINAPI d3dx9_skin_info_Release(ID3DXSkinInfo *iface)
for
(
i
=
0
;
i
<
skin
->
num_bones
;
++
i
)
{
HeapFree
(
GetProcessHeap
(),
0
,
skin
->
bones
[
i
].
name
);
HeapFree
(
GetProcessHeap
(),
0
,
skin
->
bones
[
i
].
vertices
);
HeapFree
(
GetProcessHeap
(),
0
,
skin
->
bones
[
i
].
weights
);
free
(
skin
->
bones
[
i
].
name
);
free
(
skin
->
bones
[
i
].
vertices
);
free
(
skin
->
bones
[
i
].
weights
);
}
HeapFree
(
GetProcessHeap
(),
0
,
skin
->
bones
);
HeapFree
(
GetProcessHeap
(),
0
,
skin
);
free
(
skin
->
bones
);
free
(
skin
);
}
return
refcount
;
...
...
@@ -114,12 +114,12 @@ static HRESULT WINAPI d3dx9_skin_info_SetBoneInfluence(ID3DXSkinInfo *iface,
return
D3DERR_INVALIDCALL
;
if
(
num_influences
)
{
new_vertices
=
HeapAlloc
(
GetProcessHeap
(),
0
,
num_influences
*
sizeof
(
*
vertices
));
new_vertices
=
malloc
(
num_influences
*
sizeof
(
*
vertices
));
if
(
!
new_vertices
)
return
E_OUTOFMEMORY
;
new_weights
=
HeapAlloc
(
GetProcessHeap
(),
0
,
num_influences
*
sizeof
(
*
weights
));
new_weights
=
malloc
(
num_influences
*
sizeof
(
*
weights
));
if
(
!
new_weights
)
{
HeapFree
(
GetProcessHeap
(),
0
,
new_vertices
);
free
(
new_vertices
);
return
E_OUTOFMEMORY
;
}
memcpy
(
new_vertices
,
vertices
,
num_influences
*
sizeof
(
*
vertices
));
...
...
@@ -127,8 +127,8 @@ static HRESULT WINAPI d3dx9_skin_info_SetBoneInfluence(ID3DXSkinInfo *iface,
}
bone
=
&
skin
->
bones
[
bone_num
];
bone
->
num_influences
=
num_influences
;
HeapFree
(
GetProcessHeap
(),
0
,
bone
->
vertices
);
HeapFree
(
GetProcessHeap
(),
0
,
bone
->
weights
);
free
(
bone
->
vertices
);
free
(
bone
->
weights
);
bone
->
vertices
=
new_vertices
;
bone
->
weights
=
new_weights
;
...
...
@@ -240,19 +240,16 @@ static HRESULT WINAPI d3dx9_skin_info_SetBoneName(ID3DXSkinInfo *iface, DWORD bo
{
struct
d3dx9_skin_info
*
skin
=
impl_from_ID3DXSkinInfo
(
iface
);
char
*
new_name
;
size_t
size
;
TRACE
(
"iface %p, bone_idx %lu, name %s.
\n
"
,
iface
,
bone_idx
,
debugstr_a
(
name
));
if
(
bone_idx
>=
skin
->
num_bones
||
!
name
)
return
D3DERR_INVALIDCALL
;
size
=
strlen
(
name
)
+
1
;
new_name
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
new_name
=
strdup
(
name
);
if
(
!
new_name
)
return
E_OUTOFMEMORY
;
memcpy
(
new_name
,
name
,
size
);
HeapFree
(
GetProcessHeap
(),
0
,
skin
->
bones
[
bone_idx
].
name
);
free
(
skin
->
bones
[
bone_idx
].
name
);
skin
->
bones
[
bone_idx
].
name
=
new_name
;
return
D3D_OK
;
...
...
@@ -476,7 +473,7 @@ HRESULT WINAPI D3DXCreateSkinInfo(DWORD vertex_count, const D3DVERTEXELEMENT9 *d
if
(
!
skin_info
||
!
declaration
)
return
D3DERR_INVALIDCALL
;
object
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
object
));
object
=
calloc
(
1
,
sizeof
(
*
object
));
if
(
!
object
)
return
E_OUTOFMEMORY
;
...
...
@@ -487,7 +484,7 @@ HRESULT WINAPI D3DXCreateSkinInfo(DWORD vertex_count, const D3DVERTEXELEMENT9 *d
object
->
vertex_declaration
[
0
]
=
empty_declaration
;
object
->
fvf
=
0
;
object
->
bones
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
bone_count
*
sizeof
(
*
object
->
bones
));
object
->
bones
=
calloc
(
bone_count
,
sizeof
(
*
object
->
bones
));
if
(
!
object
->
bones
)
{
hr
=
E_OUTOFMEMORY
;
goto
error
;
...
...
@@ -500,8 +497,8 @@ HRESULT WINAPI D3DXCreateSkinInfo(DWORD vertex_count, const D3DVERTEXELEMENT9 *d
return
D3D_OK
;
error:
HeapFree
(
GetProcessHeap
(),
0
,
object
->
bones
);
HeapFree
(
GetProcessHeap
(),
0
,
object
);
free
(
object
->
bones
);
free
(
object
);
return
hr
;
}
...
...
dlls/d3dx9_36/sprite.c
View file @
17da2665
...
...
@@ -121,7 +121,7 @@ static ULONG WINAPI d3dx9_sprite_Release(ID3DXSprite *iface)
}
}
HeapFree
(
GetProcessHeap
(),
0
,
sprite
->
sprites
);
free
(
sprite
->
sprites
);
}
if
(
sprite
->
stateblock
)
...
...
@@ -130,7 +130,7 @@ static ULONG WINAPI d3dx9_sprite_Release(ID3DXSprite *iface)
IDirect3DVertexDeclaration9_Release
(
sprite
->
vdecl
);
if
(
sprite
->
device
)
IDirect3DDevice9_Release
(
sprite
->
device
);
HeapFree
(
GetProcessHeap
(),
0
,
sprite
);
free
(
sprite
);
}
return
refcount
;
...
...
@@ -344,6 +344,7 @@ static HRESULT WINAPI d3dx9_sprite_Draw(ID3DXSprite *iface, IDirect3DTexture9 *t
struct
d3dx9_sprite
*
This
=
impl_from_ID3DXSprite
(
iface
);
struct
sprite
*
new_sprites
;
D3DSURFACE_DESC
texdesc
;
int
new_size
;
TRACE
(
"iface %p, texture %p, rect %s, center %p, position %p, color 0x%08lx.
\n
"
,
iface
,
texture
,
wine_dbgstr_rect
(
rect
),
center
,
position
,
color
);
...
...
@@ -351,19 +352,14 @@ static HRESULT WINAPI d3dx9_sprite_Draw(ID3DXSprite *iface, IDirect3DTexture9 *t
if
(
texture
==
NULL
)
return
D3DERR_INVALIDCALL
;
if
(
!
This
->
ready
)
return
D3DERR_INVALIDCALL
;
if
(
!
This
->
allocated_sprites
)
if
(
This
->
allocated_sprites
<=
This
->
sprite_count
)
{
This
->
sprites
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
32
*
sizeof
(
*
This
->
sprites
));
This
->
allocated_sprites
=
32
;
}
else
if
(
This
->
allocated_sprites
<=
This
->
sprite_count
)
{
new_sprites
=
HeapReAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
This
->
sprites
,
This
->
allocated_sprites
*
2
*
sizeof
(
*
This
->
sprites
));
new_size
=
This
->
allocated_sprites
?
This
->
allocated_sprites
*
2
:
32
;
new_sprites
=
realloc
(
This
->
sprites
,
new_size
*
sizeof
(
*
This
->
sprites
));
if
(
!
new_sprites
)
return
E_OUTOFMEMORY
;
This
->
sprites
=
new_sprites
;
This
->
allocated_sprites
*=
2
;
This
->
allocated_sprites
=
new_size
;
}
This
->
sprites
[
This
->
sprite_count
].
texture
=
texture
;
if
(
!
(
This
->
flags
&
D3DXSPRITE_DO_NOT_ADDREF_TEXTURE
))
...
...
@@ -418,7 +414,7 @@ static HRESULT WINAPI d3dx9_sprite_Flush(ID3DXSprite *iface)
if
(
!
This
->
sprite_count
)
return
D3D_OK
;
/* TODO: use of a vertex buffer here */
vertices
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
vertices
)
*
6
*
This
->
sprite_count
);
vertices
=
malloc
(
sizeof
(
*
vertices
)
*
6
*
This
->
sprite_count
);
for
(
start
=
0
;
start
<
This
->
sprite_count
;
start
+=
count
,
count
=
0
)
{
i
=
start
;
...
...
@@ -467,7 +463,7 @@ static HRESULT WINAPI d3dx9_sprite_Flush(ID3DXSprite *iface)
IDirect3DDevice9_DrawPrimitiveUP
(
This
->
device
,
D3DPT_TRIANGLELIST
,
2
*
count
,
vertices
+
6
*
start
,
sizeof
(
*
vertices
));
}
HeapFree
(
GetProcessHeap
(),
0
,
vertices
);
free
(
vertices
);
if
(
!
(
This
->
flags
&
D3DXSPRITE_DO_NOT_ADDREF_TEXTURE
))
for
(
i
=
0
;
i
<
This
->
sprite_count
;
i
++
)
...
...
@@ -571,7 +567,7 @@ HRESULT WINAPI D3DXCreateSprite(struct IDirect3DDevice9 *device, struct ID3DXSpr
if
(
device
==
NULL
||
sprite
==
NULL
)
return
D3DERR_INVALIDCALL
;
if
(
!
(
object
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
*
object
))))
if
(
!
(
object
=
calloc
(
1
,
sizeof
(
*
object
))))
{
*
sprite
=
NULL
;
return
E_OUTOFMEMORY
;
...
...
dlls/d3dx9_36/surface.c
View file @
17da2665
...
...
@@ -869,7 +869,7 @@ static BOOL convert_dib_to_bmp(const void **data, unsigned int *size)
TRACE
(
"Converting DIB file to BMP
\n
"
);
new_size
=
*
size
+
sizeof
(
BITMAPFILEHEADER
);
new_data
=
HeapAlloc
(
GetProcessHeap
(),
0
,
new_size
);
new_data
=
malloc
(
new_size
);
CopyMemory
(
new_data
+
sizeof
(
BITMAPFILEHEADER
),
*
data
,
*
size
);
/* Add BMP header */
...
...
@@ -1058,7 +1058,7 @@ HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(const void *data, UINT datasize,
IWICBitmapDecoder_Release
(
decoder
);
if
(
dib
)
HeapFree
(
GetProcessHeap
(),
0
,
(
void
*
)
data
);
free
(
(
void
*
)
data
);
if
(
FAILED
(
hr
))
{
TRACE
(
"Invalid or unsupported image file
\n
"
);
...
...
@@ -1090,11 +1090,11 @@ HRESULT WINAPI D3DXGetImageInfoFromFileA(const char *file, D3DXIMAGE_INFO *info)
if
(
!
file
)
return
D3DERR_INVALIDCALL
;
strlength
=
MultiByteToWideChar
(
CP_ACP
,
0
,
file
,
-
1
,
NULL
,
0
);
widename
=
HeapAlloc
(
GetProcessHeap
(),
0
,
strlength
*
sizeof
(
*
widename
));
widename
=
malloc
(
strlength
*
sizeof
(
*
widename
));
MultiByteToWideChar
(
CP_ACP
,
0
,
file
,
-
1
,
widename
,
strlength
);
hr
=
D3DXGetImageInfoFromFileW
(
widename
,
info
);
HeapFree
(
GetProcessHeap
(),
0
,
widename
);
free
(
widename
);
return
hr
;
}
...
...
@@ -1286,7 +1286,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(IDirect3DSurface9 *pDestSurface,
WICColor
*
colors
=
NULL
;
pitch
=
formatdesc
->
bytes_per_pixel
*
wicrect
.
Width
;
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
pitch
*
wicrect
.
Height
);
buffer
=
malloc
(
pitch
*
wicrect
.
Height
);
hr
=
IWICBitmapFrameDecode_CopyPixels
(
bitmapframe
,
&
wicrect
,
pitch
,
pitch
*
wicrect
.
Height
,
buffer
);
...
...
@@ -1303,8 +1303,8 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(IDirect3DSurface9 *pDestSurface,
hr
=
IWICPalette_GetColorCount
(
wic_palette
,
&
nb_colors
);
if
(
SUCCEEDED
(
hr
))
{
colors
=
HeapAlloc
(
GetProcessHeap
(),
0
,
nb_colors
*
sizeof
(
colors
[
0
]));
palette
=
HeapAlloc
(
GetProcessHeap
(),
0
,
nb_colors
*
sizeof
(
palette
[
0
]));
colors
=
malloc
(
nb_colors
*
sizeof
(
colors
[
0
]));
palette
=
malloc
(
nb_colors
*
sizeof
(
palette
[
0
]));
if
(
!
colors
||
!
palette
)
hr
=
E_OUTOFMEMORY
;
}
...
...
@@ -1334,9 +1334,9 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(IDirect3DSurface9 *pDestSurface,
palette
,
&
rect
,
dwFilter
,
Colorkey
);
}
HeapFree
(
GetProcessHeap
(),
0
,
colors
);
HeapFree
(
GetProcessHeap
(),
0
,
palette
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
free
(
colors
);
free
(
palette
);
free
(
buffer
);
}
IWICBitmapFrameDecode_Release
(
bitmapframe
);
...
...
@@ -1349,7 +1349,7 @@ cleanup_err:
IWICImagingFactory_Release
(
factory
);
if
(
imginfo
.
ImageFileFormat
==
D3DXIFF_DIB
)
HeapFree
(
GetProcessHeap
(),
0
,
(
void
*
)
pSrcData
);
free
(
(
void
*
)
pSrcData
);
if
(
FAILED
(
hr
))
return
D3DXERR_INVALIDDATA
;
...
...
@@ -1377,12 +1377,12 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileA(IDirect3DSurface9 *dst_surface,
return
D3DERR_INVALIDCALL
;
strlength
=
MultiByteToWideChar
(
CP_ACP
,
0
,
src_file
,
-
1
,
NULL
,
0
);
src_file_w
=
HeapAlloc
(
GetProcessHeap
(),
0
,
strlength
*
sizeof
(
*
src_file_w
));
src_file_w
=
malloc
(
strlength
*
sizeof
(
*
src_file_w
));
MultiByteToWideChar
(
CP_ACP
,
0
,
src_file
,
-
1
,
src_file_w
,
strlength
);
hr
=
D3DXLoadSurfaceFromFileW
(
dst_surface
,
dst_palette
,
dst_rect
,
src_file_w
,
src_rect
,
filter
,
color_key
,
src_info
);
HeapFree
(
GetProcessHeap
(),
0
,
src_file_w
);
free
(
src_file_w
);
return
hr
;
}
...
...
@@ -2040,7 +2040,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
src_pitch
=
src_pitch
*
srcformatdesc
->
block_width
/
srcformatdesc
->
block_byte_count
;
src_uncompressed
=
heap_
alloc
(
src_size
.
width
*
src_size
.
height
*
sizeof
(
DWORD
));
src_uncompressed
=
m
alloc
(
src_size
.
width
*
src_size
.
height
*
sizeof
(
DWORD
));
if
(
!
src_uncompressed
)
{
unlock_surface
(
dst_surface
,
&
dst_rect_aligned
,
surface
,
FALSE
);
...
...
@@ -2086,15 +2086,16 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
||
dst_rect
->
top
!=
dst_rect_aligned
.
top
||
dst_rect
->
right
!=
dst_rect_aligned
.
right
||
dst_rect
->
bottom
!=
dst_rect_aligned
.
bottom
;
size_t
dst_uncompressed_size
=
dst_size_aligned
.
width
*
dst_size_aligned
.
height
*
sizeof
(
DWORD
);
dst_uncompressed
=
HeapAlloc
(
GetProcessHeap
(),
dst_misaligned
?
HEAP_ZERO_MEMORY
:
0
,
dst_size_aligned
.
width
*
dst_size_aligned
.
height
*
sizeof
(
DWORD
));
dst_uncompressed
=
malloc
(
dst_uncompressed_size
);
if
(
!
dst_uncompressed
)
{
heap_
free
(
src_uncompressed
);
free
(
src_uncompressed
);
unlock_surface
(
dst_surface
,
&
dst_rect_aligned
,
surface
,
FALSE
);
return
E_OUTOFMEMORY
;
}
if
(
dst_misaligned
)
memset
(
dst_uncompressed
,
0
,
dst_uncompressed_size
);
dst_pitch
=
dst_size_aligned
.
width
*
sizeof
(
DWORD
);
dst_format
=
get_format_info
(
D3DFMT_A8B8G8R8
);
dst_mem
=
dst_uncompressed
+
(
dst_rect
->
top
-
dst_rect_aligned
.
top
)
*
dst_pitch
...
...
@@ -2123,7 +2124,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
dst_mem
,
dst_pitch
,
0
,
&
dst_size
,
dst_format
,
color_key
,
src_palette
);
}
heap_
free
(
src_uncompressed
);
free
(
src_uncompressed
);
if
(
dst_uncompressed
)
{
...
...
@@ -2149,7 +2150,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
tx_compress_dxtn
(
4
,
dst_size_aligned
.
width
,
dst_size_aligned
.
height
,
dst_uncompressed
,
gl_format
,
lockrect
.
pBits
,
lockrect
.
Pitch
);
heap_
free
(
dst_uncompressed
);
free
(
dst_uncompressed
);
}
}
...
...
@@ -2323,7 +2324,7 @@ HRESULT WINAPI D3DXSaveSurfaceToFileA(const char *dst_filename, D3DXIMAGE_FILEFO
if
(
!
dst_filename
)
return
D3DERR_INVALIDCALL
;
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
dst_filename
,
-
1
,
NULL
,
0
);
filename
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
));
filename
=
malloc
(
len
*
sizeof
(
WCHAR
));
if
(
!
filename
)
return
E_OUTOFMEMORY
;
MultiByteToWideChar
(
CP_ACP
,
0
,
dst_filename
,
-
1
,
filename
,
len
);
...
...
@@ -2334,7 +2335,7 @@ HRESULT WINAPI D3DXSaveSurfaceToFileA(const char *dst_filename, D3DXIMAGE_FILEFO
ID3DXBuffer_Release
(
buffer
);
}
HeapFree
(
GetProcessHeap
(),
0
,
filename
);
free
(
filename
);
return
hr
;
}
...
...
@@ -2507,7 +2508,7 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE
size
.
height
=
height
;
size
.
depth
=
1
;
dst_pitch
=
width
*
dst_format_desc
->
bytes_per_pixel
;
dst_data
=
HeapAlloc
(
GetProcessHeap
(),
0
,
dst_pitch
*
height
);
dst_data
=
malloc
(
dst_pitch
*
height
);
if
(
!
dst_data
)
{
hr
=
E_OUTOFMEMORY
;
...
...
@@ -2515,7 +2516,7 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE
}
if
(
FAILED
(
hr
=
lock_surface
(
src_surface
,
src_rect
,
&
locked_rect
,
&
temp_surface
,
FALSE
)))
{
HeapFree
(
GetProcessHeap
(),
0
,
dst_data
);
free
(
dst_data
);
goto
cleanup
;
}
convert_argb_pixels
(
locked_rect
.
pBits
,
locked_rect
.
Pitch
,
0
,
&
size
,
src_format_desc
,
...
...
@@ -2523,7 +2524,7 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE
unlock_surface
(
src_surface
,
src_rect
,
temp_surface
,
FALSE
);
IWICBitmapFrameEncode_WritePixels
(
frame
,
height
,
dst_pitch
,
dst_pitch
*
height
,
dst_data
);
HeapFree
(
GetProcessHeap
(),
0
,
dst_data
);
free
(
dst_data
);
}
hr
=
IWICBitmapFrameEncode_Commit
(
frame
);
...
...
dlls/d3dx9_36/texture.c
View file @
17da2665
...
...
@@ -801,14 +801,14 @@ HRESULT WINAPI D3DXCreateTextureFromFileExA(struct IDirect3DDevice9 *device, con
return
D3DERR_INVALIDCALL
;
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
srcfile
,
-
1
,
NULL
,
0
);
widename
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
*
widename
));
widename
=
malloc
(
len
*
sizeof
(
*
widename
));
MultiByteToWideChar
(
CP_ACP
,
0
,
srcfile
,
-
1
,
widename
,
len
);
hr
=
D3DXCreateTextureFromFileExW
(
device
,
widename
,
width
,
height
,
miplevels
,
usage
,
format
,
pool
,
filter
,
mipfilter
,
colorkey
,
srcinfo
,
palette
,
texture
);
HeapFree
(
GetProcessHeap
(),
0
,
widename
);
free
(
widename
);
return
hr
;
}
...
...
@@ -981,12 +981,12 @@ HRESULT WINAPI D3DXCreateVolumeTextureFromFileA(IDirect3DDevice9 *device,
if
(
!
filename
)
return
D3DERR_INVALIDCALL
;
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
filename
,
-
1
,
NULL
,
0
);
filenameW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
));
filenameW
=
malloc
(
len
*
sizeof
(
WCHAR
));
if
(
!
filenameW
)
return
E_OUTOFMEMORY
;
MultiByteToWideChar
(
CP_ACP
,
0
,
filename
,
-
1
,
filenameW
,
len
);
hr
=
map_view_of_file
(
filenameW
,
&
data
,
&
data_size
);
HeapFree
(
GetProcessHeap
(),
0
,
filenameW
);
free
(
filenameW
);
if
(
FAILED
(
hr
))
return
D3DXERR_INVALIDDATA
;
hr
=
D3DXCreateVolumeTextureFromFileInMemoryEx
(
device
,
data
,
data_size
,
D3DX_DEFAULT
,
D3DX_DEFAULT
,
D3DX_DEFAULT
,
...
...
@@ -1049,12 +1049,12 @@ HRESULT WINAPI D3DXCreateVolumeTextureFromFileExA(IDirect3DDevice9 *device,
if
(
!
filename
)
return
D3DERR_INVALIDCALL
;
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
filename
,
-
1
,
NULL
,
0
);
filenameW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
));
filenameW
=
malloc
(
len
*
sizeof
(
WCHAR
));
if
(
!
filenameW
)
return
E_OUTOFMEMORY
;
MultiByteToWideChar
(
CP_ACP
,
0
,
filename
,
-
1
,
filenameW
,
len
);
hr
=
map_view_of_file
(
filenameW
,
&
data
,
&
data_size
);
HeapFree
(
GetProcessHeap
(),
0
,
filenameW
);
free
(
filenameW
);
if
(
FAILED
(
hr
))
return
D3DXERR_INVALIDDATA
;
hr
=
D3DXCreateVolumeTextureFromFileInMemoryEx
(
device
,
data
,
data_size
,
width
,
height
,
depth
,
...
...
@@ -1520,14 +1520,14 @@ HRESULT WINAPI D3DXCreateCubeTextureFromFileA(IDirect3DDevice9 *device,
if
(
!
src_filename
)
return
D3DERR_INVALIDCALL
;
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
src_filename
,
-
1
,
NULL
,
0
);
filename
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
));
filename
=
malloc
(
len
*
sizeof
(
WCHAR
));
if
(
!
filename
)
return
E_OUTOFMEMORY
;
MultiByteToWideChar
(
CP_ACP
,
0
,
src_filename
,
-
1
,
filename
,
len
);
hr
=
map_view_of_file
(
filename
,
&
data
,
&
data_size
);
if
(
FAILED
(
hr
))
{
HeapFree
(
GetProcessHeap
(),
0
,
filename
);
free
(
filename
);
return
D3DXERR_INVALIDDATA
;
}
...
...
@@ -1535,7 +1535,7 @@ HRESULT WINAPI D3DXCreateCubeTextureFromFileA(IDirect3DDevice9 *device,
0
,
D3DFMT_UNKNOWN
,
D3DPOOL_MANAGED
,
D3DX_DEFAULT
,
D3DX_DEFAULT
,
0
,
NULL
,
NULL
,
cube_texture
);
UnmapViewOfFile
(
data
);
HeapFree
(
GetProcessHeap
(),
0
,
filename
);
free
(
filename
);
return
hr
;
}
...
...
@@ -1578,14 +1578,14 @@ HRESULT WINAPI D3DXCreateCubeTextureFromFileExA(IDirect3DDevice9 *device, const
if
(
!
src_filename
)
return
D3DERR_INVALIDCALL
;
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
src_filename
,
-
1
,
NULL
,
0
);
filename
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
));
filename
=
malloc
(
len
*
sizeof
(
WCHAR
));
if
(
!
filename
)
return
E_OUTOFMEMORY
;
MultiByteToWideChar
(
CP_ACP
,
0
,
src_filename
,
-
1
,
filename
,
len
);
hr
=
map_view_of_file
(
filename
,
&
data
,
&
data_size
);
if
(
FAILED
(
hr
))
{
HeapFree
(
GetProcessHeap
(),
0
,
filename
);
free
(
filename
);
return
D3DXERR_INVALIDDATA
;
}
...
...
@@ -1593,7 +1593,7 @@ HRESULT WINAPI D3DXCreateCubeTextureFromFileExA(IDirect3DDevice9 *device, const
usage
,
format
,
pool
,
filter
,
mip_filter
,
color_key
,
image_info
,
palette
,
cube_texture
);
UnmapViewOfFile
(
data
);
HeapFree
(
GetProcessHeap
(),
0
,
filename
);
free
(
filename
);
return
hr
;
}
...
...
@@ -1809,7 +1809,7 @@ HRESULT WINAPI D3DXSaveTextureToFileA(const char *dst_filename, D3DXIMAGE_FILEFO
if
(
!
dst_filename
)
return
D3DERR_INVALIDCALL
;
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
dst_filename
,
-
1
,
NULL
,
0
);
filename
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
));
filename
=
malloc
(
len
*
sizeof
(
WCHAR
));
if
(
!
filename
)
return
E_OUTOFMEMORY
;
MultiByteToWideChar
(
CP_ACP
,
0
,
dst_filename
,
-
1
,
filename
,
len
);
...
...
@@ -1820,7 +1820,7 @@ HRESULT WINAPI D3DXSaveTextureToFileA(const char *dst_filename, D3DXIMAGE_FILEFO
ID3DXBuffer_Release
(
buffer
);
}
HeapFree
(
GetProcessHeap
(),
0
,
filename
);
free
(
filename
);
return
hr
;
}
...
...
dlls/d3dx9_36/volume.c
View file @
17da2665
...
...
@@ -36,13 +36,13 @@ HRESULT WINAPI D3DXLoadVolumeFromFileA(IDirect3DVolume9 *dst_volume, const PALET
if
(
!
dst_volume
||
!
filename
)
return
D3DERR_INVALIDCALL
;
length
=
MultiByteToWideChar
(
CP_ACP
,
0
,
filename
,
-
1
,
NULL
,
0
);
filenameW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
length
*
sizeof
(
*
filenameW
));
filenameW
=
malloc
(
length
*
sizeof
(
*
filenameW
));
if
(
!
filenameW
)
return
E_OUTOFMEMORY
;
MultiByteToWideChar
(
CP_ACP
,
0
,
filename
,
-
1
,
filenameW
,
length
);
hr
=
D3DXLoadVolumeFromFileW
(
dst_volume
,
dst_palette
,
dst_box
,
filenameW
,
src_box
,
filter
,
color_key
,
info
);
HeapFree
(
GetProcessHeap
(),
0
,
filenameW
);
free
(
filenameW
);
return
hr
;
}
...
...
dlls/d3dx9_36/xfile.c
View file @
17da2665
...
...
@@ -129,9 +129,9 @@ static ULONG WINAPI d3dx9_file_data_Release(ID3DXFileData *iface)
ID3DXFileData
*
child
=
file_data
->
children
[
i
];
child
->
lpVtbl
->
Release
(
child
);
}
HeapFree
(
GetProcessHeap
(),
0
,
file_data
->
children
);
free
(
file_data
->
children
);
IDirectXFileData_Release
(
file_data
->
dxfile_data
);
HeapFree
(
GetProcessHeap
(),
0
,
file_data
);
free
(
file_data
);
}
return
refcount
;
...
...
@@ -303,7 +303,7 @@ static HRESULT d3dx9_file_data_create(IDirectXFileObject *dxfile_object, ID3DXFi
*
ret_iface
=
NULL
;
object
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
*
object
));
object
=
calloc
(
1
,
sizeof
(
*
object
));
if
(
!
object
)
return
E_OUTOFMEMORY
;
...
...
@@ -322,7 +322,7 @@ static HRESULT d3dx9_file_data_create(IDirectXFileObject *dxfile_object, ID3DXFi
IUnknown_Release
(
reference
);
if
(
FAILED
(
ret
))
{
HeapFree
(
GetProcessHeap
(),
0
,
object
);
free
(
object
);
return
E_FAIL
;
}
object
->
reference
=
TRUE
;
...
...
@@ -330,7 +330,7 @@ static HRESULT d3dx9_file_data_create(IDirectXFileObject *dxfile_object, ID3DXFi
else
{
FIXME
(
"Don't know what to do with binary object
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
object
);
free
(
object
);
return
E_FAIL
;
}
}
...
...
@@ -341,17 +341,8 @@ static HRESULT d3dx9_file_data_create(IDirectXFileObject *dxfile_object, ID3DXFi
{
ID3DXFileData
**
new_children
;
if
(
object
->
children
)
{
children_array_size
*=
2
;
new_children
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
object
->
children
,
sizeof
(
*
object
->
children
)
*
children_array_size
);
}
else
{
children_array_size
=
4
;
new_children
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
object
->
children
)
*
children_array_size
);
}
children_array_size
=
object
->
children
?
children_array_size
*
2
:
4
;
new_children
=
realloc
(
object
->
children
,
sizeof
(
*
object
->
children
)
*
children_array_size
);
if
(
!
new_children
)
{
ret
=
E_OUTOFMEMORY
;
...
...
@@ -374,8 +365,7 @@ static HRESULT d3dx9_file_data_create(IDirectXFileObject *dxfile_object, ID3DXFi
{
ID3DXFileData
**
new_children
;
new_children
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
object
->
children
,
sizeof
(
*
object
->
children
)
*
object
->
child_count
);
new_children
=
realloc
(
object
->
children
,
sizeof
(
*
object
->
children
)
*
object
->
child_count
);
if
(
new_children
)
object
->
children
=
new_children
;
}
...
...
@@ -431,8 +421,8 @@ static ULONG WINAPI d3dx9_file_enum_object_Release(ID3DXFileEnumObject *iface)
ID3DXFileData
*
child
=
file_enum
->
children
[
i
];
child
->
lpVtbl
->
Release
(
child
);
}
HeapFree
(
GetProcessHeap
(),
0
,
file_enum
->
children
);
HeapFree
(
GetProcessHeap
(),
0
,
file_enum
);
free
(
file_enum
->
children
);
free
(
file_enum
);
}
return
refcount
;
...
...
@@ -540,7 +530,7 @@ static ULONG WINAPI d3dx9_file_Release(ID3DXFile *iface)
if
(
!
refcount
)
{
IDirectXFile_Release
(
file
->
dxfile
);
HeapFree
(
GetProcessHeap
(),
0
,
file
);
free
(
file
);
}
return
refcount
;
...
...
@@ -597,7 +587,7 @@ static HRESULT WINAPI d3dx9_file_CreateEnumObject(ID3DXFile *iface, const void *
return
E_NOTIMPL
;
}
object
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
*
object
));
object
=
calloc
(
1
,
sizeof
(
*
object
));
if
(
!
object
)
return
E_OUTOFMEMORY
;
...
...
@@ -608,7 +598,7 @@ static HRESULT WINAPI d3dx9_file_CreateEnumObject(ID3DXFile *iface, const void *
if
(
ret
!=
S_OK
)
{
HeapFree
(
GetProcessHeap
(),
0
,
object
);
free
(
object
);
return
ret
;
}
...
...
@@ -619,17 +609,8 @@ static HRESULT WINAPI d3dx9_file_CreateEnumObject(ID3DXFile *iface, const void *
{
ID3DXFileData
**
new_children
;
if
(
object
->
children
)
{
children_array_size
*=
2
;
new_children
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
object
->
children
,
sizeof
(
*
object
->
children
)
*
children_array_size
);
}
else
{
children_array_size
=
4
;
new_children
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
object
->
children
)
*
children_array_size
);
}
children_array_size
=
object
->
children
?
children_array_size
*
2
:
4
;
new_children
=
realloc
(
object
->
children
,
sizeof
(
*
object
->
children
)
*
children_array_size
);
if
(
!
new_children
)
{
ret
=
E_OUTOFMEMORY
;
...
...
@@ -648,8 +629,7 @@ static HRESULT WINAPI d3dx9_file_CreateEnumObject(ID3DXFile *iface, const void *
{
ID3DXFileData
**
new_children
;
new_children
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
object
->
children
,
sizeof
(
*
object
->
children
)
*
object
->
child_count
);
new_children
=
realloc
(
object
->
children
,
sizeof
(
*
object
->
children
)
*
object
->
child_count
);
if
(
new_children
)
object
->
children
=
new_children
;
}
...
...
@@ -722,14 +702,14 @@ HRESULT WINAPI D3DXFileCreate(ID3DXFile **d3dxfile)
*
d3dxfile
=
NULL
;
object
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
object
));
object
=
calloc
(
1
,
sizeof
(
*
object
));
if
(
!
object
)
return
E_OUTOFMEMORY
;
ret
=
DirectXFileCreate
(
&
object
->
dxfile
);
if
(
ret
!=
S_OK
)
{
HeapFree
(
GetProcessHeap
(),
0
,
object
);
free
(
object
);
if
(
ret
==
E_OUTOFMEMORY
)
return
ret
;
return
E_FAIL
;
...
...
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