游戏开发论坛

 找回密码
 立即注册
搜索
查看: 4342|回复: 3

关于SAFE_RELEASE宏

[复制链接]

1

主题

2

帖子

0

积分

新手上路

Rank: 1

积分
0
发表于 2012-8-18 21:23:00 | 显示全部楼层 |阅读模式
其中头文件定义了这样一个宏


#define V_RETURN(X)        { hr = x; if( FAILED( hr ) ) { return hr; } }       


然后程序中析构函数种的都是用这个宏释放资源的,

SAFE_RELEASE(m_pD3D);比如说m_pD3D是指向IDirect3D9 Interface的指针

可IDirect3D9 Interface没有Release()成员函数

这样不就会内存泄露了么??


求解,如何可以,为什么可以这样用

1万

主题

1万

帖子

2万

积分

管理员

中级会员

Rank: 9Rank: 9Rank: 9

积分
20517
发表于 2012-8-18 21:38:00 | 显示全部楼层

Re:关于SAFE_RELEASE宏

IDirect3D9 Interface应该有Release()把,不然会编译不过。

11

主题

95

帖子

658

积分

高级会员

Rank: 4

积分
658
发表于 2012-8-18 22:20:00 | 显示全部楼层

Re:关于SAFE_RELEASE宏

是接口的话都有继承自IUnknow,那就一定有Release函数嘛! 而且没有的话在编译期间就会报错了!

1

主题

2

帖子

0

积分

新手上路

Rank: 1

积分
0
 楼主| 发表于 2012-8-18 22:27:00 | 显示全部楼层

Re: Re:关于SAFE_RELEASE宏

秋风扫走廊: Re:关于SAFE_RELEASE宏

是接口的话都有继承自IUnknow,那就一定有Release函数嘛! 而且没有的话在编译期间就会报错了!

感谢


The IDirect3D9 interface inherits from the IUnknown interface. IDirect3D9 also defines the following types of members:

The IUnknown interface is the OLE interface from which AVIFile and AVIStream interfaces are derived. Interfaces used with AVI files rely on definitions of the QueryInterface, AddRef, and Release methods from this interface.


您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-6-14 04:22

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表