An error occurred while fetching folder content.
Jonathan Schöbel
authored
The method SH_NodeFragment_get_attr provides a pointer to an Attr, by its index. Note, that it directly points to the internal data, instead of copying the data to a new Attr, which would be unneccessary overhead, if only reading access is needed. That's why it is also a const pointer. If the user intends to modify it, a copy should be taken via SH_Attr_copy. Multiple insert methods allow either to add an existing Attr, or to create a new one implicitly. If the Attr is not already used beforehand, it is more efficient to call the attr_new methods. Also an old Attr is freed, after it was inserted, thus it can't be used afterwards. This is neccessary, as for efficiency reasons an array of Attr is used directly, instead of the indirect approach of storing a pointer of Attr. This means, that the contents of the Attr has to be copied to the internal structure. If the old Attr would be left unfreed, there would be two Attrs, the original one and the implicit one, referring to the same data, which would lead to at least data corruption, or undefined behaviour like a double free, which would be a serious threat for a library which is to be used on a webserver. ... For each of the two insert modes, there is a method to prepend, append or insert at a specific position. An incorrect position is handled inside of the external method and an E_VALUE is thrown. The internal method doesn't handle this, so special care must be taken to not make undefined behaviour. However enforcing this check would be unneccessary overhead for the prepend and append methods, which are known to have correct indicies, as well for other internal methods, where the internal method may be used. The tests for the new methods are still missing, as well as the methods to remove an Attr. As the implementation is already a bit dated, the changes are commited now anyways.
Name | Last commit | Last update |
---|