Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Improve API docu of high-level API #2774
I will update the documentation. But it is actually not so easy to say how long
The pointer returned by
What can be said is that there are two cases where the pointer definitely becomes invalid:
However, since any
In short I would say, if you need a long-term copy of the value
As for the struct functionality of the code-generation API. If you use
Maybe you can improve the life-time guarantees by making elektraSetString not replacing the Key but updating the value?
Wouldn't be it also make sense that elektraGet could call kdbGet? (Or is influenced by notification.) So maybe even the next elektraGet might invalidate in future implementations?
Yes, kdbGet invalidates keys if there is an actual update. You could keep a backup (ksDup) but this might be too expensive (it might be forever growing), better if we let the user keep the reference (see below).
What about returning a key? It is already a reference counted string.
strdup is something a user can do by him/herself anyway.
That could still invalidate the pointer. If the new value is longer than the old one, we need to realloc, which almost certainly returns a new pointer. And actually
This would eliminate the guarantee that
Again this could cause problems with the guarantees. It would make more sense to have something like
One of the goals of the high-level API is to abstract away the concept of Keys and KeySets and focus simply on configuration values.