Skip to content

Safety of keeping a component's data pointer long term. #1145

Answered by copygirl
GsLogiMaker asked this question in Q&A
Discussion options

You must be logged in to vote

I think it would be wise to consider the pointer invalid as soon as you return control to Flecs. Besides modifying entities that share the same archetype (share the same components) and modifying the components on the entity itself, one thing that also comes to mind would be if you have any sorting queries. It might be safe if you can guarantee the entity's archetype never changes, but this sounds like a design flaw from the start. If what you're trying to achieve can't be done using ECS alone, what about storing a shared pointer in the component itself?

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@GsLogiMaker
Comment options

Answer selected by GsLogiMaker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants