Do not check for non NULL pointer before HeapFree'ing it. It's
[wine] / dlls / d3dx8 / d3dxbuffer.c
CommitLineData
e31ae926
RJ
1/*
2 * ID3DXBuffer implementation
3 *
4 * Copyright 2002 Raphael Junqueira
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include "config.h"
22#include "wine/port.h"
23
e37c6e18
AJ
24#include <stdarg.h>
25
e31ae926
RJ
26#include "windef.h"
27#include "winbase.h"
28#include "winuser.h"
29#include "wingdi.h"
30#include "wine/debug.h"
31
32#include "d3d8.h"
33#include "d3dx8core_private.h"
34
35WINE_DEFAULT_DEBUG_CHANNEL(d3d);
36
37/* ID3DXBuffer IUnknown parts follow: */
38HRESULT WINAPI ID3DXBufferImpl_QueryInterface(LPD3DXBUFFER iface, REFIID riid, LPVOID* ppobj) {
f5f7a182 39 ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
e31ae926
RJ
40
41 if (IsEqualGUID(riid, &IID_IUnknown)
42 || IsEqualGUID(riid, &IID_ID3DXBuffer)) {
43 ID3DXBufferImpl_AddRef(iface);
44 *ppobj = This;
45 return D3D_OK;
46 }
47
48 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
49 return E_NOINTERFACE;
50}
51
52ULONG WINAPI ID3DXBufferImpl_AddRef(LPD3DXBUFFER iface) {
f5f7a182 53 ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
e31ae926
RJ
54 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
55 return ++(This->ref);
56}
57
58ULONG WINAPI ID3DXBufferImpl_Release(LPD3DXBUFFER iface) {
f5f7a182 59 ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
e31ae926
RJ
60 ULONG ref = --This->ref;
61 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
62 if (ref == 0) {
5ad7d858 63 HeapFree(GetProcessHeap(), 0, This->buffer);
e31ae926
RJ
64 HeapFree(GetProcessHeap(), 0, This);
65 }
66 return ref;
67}
68
69/* ID3DXBuffer Interface follow: */
70LPVOID WINAPI ID3DXBufferImpl_GetBufferPointer(LPD3DXBUFFER iface) {
f5f7a182 71 ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
e31ae926
RJ
72 return This->buffer;
73}
74
75DWORD WINAPI ID3DXBufferImpl_GetBufferSize(LPD3DXBUFFER iface) {
f5f7a182 76 ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
e31ae926
RJ
77 return This->bufferSize;
78}
79
48c4bb3c 80ID3DXBufferVtbl D3DXBuffer_Vtbl =
e31ae926 81{
e31ae926
RJ
82 ID3DXBufferImpl_QueryInterface,
83 ID3DXBufferImpl_AddRef,
84 ID3DXBufferImpl_Release,
85 ID3DXBufferImpl_GetBufferPointer,
86 ID3DXBufferImpl_GetBufferSize
87};