提问人:Irbis 提问时间:10/13/2023 更新时间:10/13/2023 访问量:51
如何释放glxChooseFBConfig返回的内存?
How to free memory returned by glxChooseFBConfig?
问:
glxChooseFBConfig
返回并按以下方式定义:GLXFBConfig*
GLXFBConfig
typedef struct __GLXFBConfigRec *GLXFBConfig;
下面是一个使用和释放内存的示例函数:glxChooseFBConfig
void fun()
{
const int attribs[] =
{
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR,
GLX_DOUBLEBUFFER, True,
GLX_RED_SIZE, 8,
GLX_GREEN_SIZE, 8,
GLX_BLUE_SIZE, 8,
GLX_ALPHA_SIZE, 8,
GLX_DEPTH_SIZE, 24,
GLX_STENCIL_SIZE, 8,
None
};
Display* dpy = XOpenDisplay(NULL);
int count = 0;
GLXFBConfig* fbconfigs = glXChooseFBConfig(dpy, DefaultScreen(dpy), attribs, &count);
//do something with fbconfigs
for(int i = 0; i < count; ++i)
{
XFree(fbconfigs[i]);
}
XFree(fbconfigs);
}
我用标志编译我的应用程序。当我运行应用程序时,我收到一个清理程序错误:怎么了?-fsanitize=address
attempting double-free
答: 暂无答案
评论
for
XFree
XFree(fbconfigs);
GLXFBConfig * glXChooseFBConfig(...