Skip to content
Snippets Groups Projects
Commit 75d83bf1 authored by Jonathan Schöbel's avatar Jonathan Schöbel
Browse files

NodeFragment: changed semantics of insert_attr_new

When there are methods in the api/abi, that take pointers to strings to
store them in the library, there are two methods to do so. Either they
are copying the string and leaving it intact, or they directly assign
the given pointer to some internal storage. While the former method, is
safer in terms of memory, as the user doesn't have to remember that he
can't use the string anymore, the latter can be more efficient, as there
is no extra strdup call, but the user is not allowed to change the
pointer, free it and also can't use the pointer, because it can't be
known whether it is already freed by the library. As it should be
decideable by the user, the library often implements both approaches,
where the method, that directly store pointers without creating a copy
contains the raw_ prefix.

The insert_attr_new methods were somewhat confusing in this regard, as
it is likely to be expected, that they were copying the string, while in
fact they did not. This is now fixed. The insert_attr_new methods copy
the strings, while the added insert_attr_raw_new methods preserve the
old behaviour of the insert_attr_new methods, thus allowing to let the
user choose, what is more appropriate.
parent 112b8438
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment