[英]flatbuffers: Is it possible to delete a buffer via root-pointer
I'm starting to use the flatbuffer library. 我开始使用flatbuffer库。 But there is a thing that feels uncomfortable for me, when it comes to delete a buffer.
但是,在删除缓冲区时,我感到有些不舒服。 I don't know ho to delete buffer via it's root-pointer-element.
我不知道豪通过其根指针元素删除缓冲区。 If this were possible the root-pointer could take the ownership of the allocated space and i've not to bother about lifetime-issues(dangling root-pointer, memory-leaks,...)
如果可能的话,根指针可以取得分配空间的所有权,而我不必担心生命周期问题(悬挂根指针,内存泄漏等)。
std::uint_8* buffer = get_buffer_for_exaple_from_file("my_monster.bin");
auto monster = MyGame::Sample::GetMonster(buffer);
///monster points somewhere in buffer
...
///now this would be very handy
delete_buffer(monster); ///buffer is deleted
Q: Is it possible (maybe under some restrictions as monster is not mutable, etc) write something like delete_buffer 问:是否有可能(可能由于怪物不可变而受到某些限制,等等)编写类似于delete_buffer的内容
The root pointer points to a location inside the buffer that is not at a known offset, so no, you can't delete the buffer through it. 根指针指向缓冲区内一个不存在已知偏移量的位置,因此,不能,您无法通过该位置删除缓冲区。 To delete the buffer, you must use the original buffer pointer.
要删除缓冲区,必须使用原始缓冲区指针。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.