什么是“userdata指针”的好定义? [英] What is a good definition of a "userdata pointer"?

查看:172
本文介绍了什么是“userdata指针”的好定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索了一个很好的解释,但找不到一个。

I have searched for a good explanation but can't find one.

我可以尝试自己写一个,但我更喜欢有更好的英语的人可以帮助我解释这对Zan Lynx的评论此处

I could try to write one myself but I'd prefer if someone with better english could help me explain this for Zan Lynx in the comment here.

...似乎应该有一个很好的解释,为什么不在这里?

...and it seems like there should be a good explanation somewhere, why not here?

推荐答案

当库代表程序管理一些数据结构(例如,GUI应用程序中的窗口由OS管理)时,它通常将这些结构的内容保留为私有。然而,对于程序来说,保持一些特定于程序对这些结构的使用的附加数据通常是有用的。因此,库通常提供对与每个结构存储的字段(通常称为用户数据)的访问。

When a library manages some data structures on behalf of a program (e.g. windows in a GUI application are managed by the OS), it usually keeps the contents of those structures private. However, it is typically useful for the program to maintain some additional data specific to the program's use of those structures. Therefore, a library will often provide access to a field (often called user data) which it stores with each structure.

通过程序的用户数据字段是在每次程序请求库创建结构时分配一些存储器,并且将指向该存储器的指针存储在由库提供的用户数据字段中,因此术语 userdata指针

A common use of the user data field by a program is to allocate some memory each time the program requests the library to create a structure, and to store the pointer to that memory in the user data field provided by the library, hence the term userdata pointer.

这篇关于什么是“userdata指针”的好定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆