- Jun 10, 2023
-
-
Jonathan Schöbel authored
-
Jonathan Schöbel authored
-
Jonathan Schöbel authored
The tests are mostly split in a variant with error checking and a variant without, as it is now common.
-
- Jun 09, 2023
-
-
Jonathan Schöbel authored
The function SH_Text_set_char allows to write a single character to a position, that already exists in the text. Thus overwriting another character. If the index is out of range, a value error is set and FALSE is returned.
-
Jonathan Schöbel authored
-
Jonathan Schöbel authored
NodeFragment is virtually finished, but TextFragment is still missing, as it depends on still not implemented functionality of SH_Text.
-
- Jun 07, 2023
-
-
Jonathan Schöbel authored
While it should not be the case, that the Attr's internal method free's the passed attribute, as some of the other internal methods pass non-allocated pointers to it, the methods visible by the user should indeed free things, where the ownership of every inner element is already transfered. This was adjusted now. As some tests have taken advantage of the fact, that while not to be changed, the old pointers were still accessible, they had to be adjusted.
-
Jonathan Schöbel authored
The demo program now uses some of the new functionality.
-
Jonathan Schöbel authored
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.
-
- Jun 06, 2023
-
-
Jonathan Schöbel authored
Fixed some memory leak detected by valgrind.
-
Jonathan Schöbel authored
-
Jonathan Schöbel authored
-
- Jun 05, 2023
-
-
Jonathan Schöbel authored
The to_html method generates also the html for the attributes. Note, that there is no escapeing of the quotes, the values are wrapped with. But this is also somewhat consistent, as there is no syntax validation on the tags either. (i.e. no '<' in side of a tag)
-
Jonathan Schöbel authored
-
Jonathan Schöbel authored
-
Jonathan Schöbel authored
The common code to cleanup in case of an error was bundled at the end of the function. For people complaining about the use of goto: this is the exact use case, where it is recommended!
-
- Jun 04, 2023
-
-
Jonathan Schöbel authored
Two alternatives are provided: remove_attr and pop_attr. While the former free's the Attr's data, the latter allocates a new Attr, to store and return the data. Both functionality is provided by a single (internal) static method.
-
- Jun 03, 2023
-
-
Jonathan Schöbel authored
This method needs to be used in places where freeing the src-pointer is not possible, as it may be not allocated. If freeing is needed, it is now in the responsibility of the caller. As it turns out this approach is not even more useful, it is also less work, as it can be determined from the fact, that adjusting the tests to the new behavior means actually removing lines, that were previously working around the quirks, that the old approach introduced.
-
Jonathan Schöbel authored
-
Jonathan Schöbel authored
Until now, the configure script just checked for check to be installed, which is needed to compile the tests. Now, configure provides a conditional (MISSING_CHECK) depending on its presence for use by automake. If check is missing, the tests aren't compiled. Instead a special script is executed to inform the user of the problem and stops the testsuite. Note, that it was not possible to directly stop the generation of the testsuite by injecting a rule to a Makefile without relying on implementation details of automake. See: https://stackoverflow.com/questions/76376806/automake-how-to-portably-throw-an-error-and-aborting-the-target/76382437 To allow the script to issue messages to stderr, AM_TESTS_FD_REDIRECT is used, because the parallel test harness redirects output of its tests to logfiles. This isn't used for the serial test harness, because there is no redirection to logfiles, but there AM_TESTS_FD_REDIRECT is also not taken into account. See: https://www.gnu.org/software/automake/manual/html_node/Testsuite-Environment-Overrides.html Additionaly configure also provides an argument to enforce both behaviours. When specifying --enable-tests=no the tests are not compiled regardless of the presence of check. If --enable-tests=yes, it is assumed, that tests are really needed and the mandantory check for check is performed thus providing the former behaviour. If not specified --enable-tests default to auto, which results in the same behaviour as --enable-tests=yes, if check is present, and like --enable-tests=no otherwise.
-
Jonathan Schöbel authored
-
Jonathan Schöbel authored
Hiding files, that are generated during build, shouldn't be a personal choice, thus they should be added to the global .gitignore. Note that in this project it is choosen, to not include generated files into the version control system, but of course they must be always included for distributions.
-
Jonathan Schöbel authored
-
Jonathan Schöbel authored
The prepend_child and append_child methods were previously not tested. They are now added to testing.
-
Jonathan Schöbel authored
Hand in still missing tests.
-
- Jun 02, 2023
-
-
Jonathan Schöbel authored
added tests for getter
-
Jonathan Schöbel authored
This is a severe bug. The purpose of Attr_free is to free the internal data, while leaving the outer structure unfreed. What is needed here is quite the opposite: freeing the outer structure but leaving the internal data intact. Of course the internal data is still needed, as it is data that was just assigned to the dest Attr. This bug introduced a double free, which is undefined behaviour with all of it's scary effects.
-
Jonathan Schöbel authored
Sometimes it is interesting to know, whether to Attr are referring to the same attribute. Note that it is not intended to provide a method for the values, as that would be meaningless on its own and if it is used in a more complex tasks, this is still possible with the current set of methods, which is prefered as the complex task can then be implemented on the outside completely.
-
Jonathan Schöbel authored
A method to compare two Attr's for exact equality was added both to internal and external methods.
-
- Jun 01, 2023
-
-
Jonathan Schöbel authored
Sometimes you want to reuse an Attr after adding it, this is done via the insert_copy methods.
-
Jonathan Schöbel authored
When a child is removed, the array may be reallocated, to not waste unused memory. If the child is removed out of the middle, all subsequent childs have to be moved. However, if it turns out that the reallocation is not currently possible, the method should return the NodeFragment in a state, as if the call to the remove method never happened. This means, that all the childs, that were moved before the realloc call, have to be moved back and the original child has also to be written back. This was forgotten, which is clearly a bug, which is fixed hereby. Note that it would be theoretically possible to not move everything back and forth, by storing the last value before the call to realloc and only in case of success move everything. While this is possible and more efficient, it is also a bit more complicated, and as this only takes effect, if the OS fails to provide memory, which should be an uncommon event, the algorithm is not changed, leaving that possible inefficient approach.
-
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.
-
- Mar 20, 2023
-
-
Jonathan Schöbel authored
-
Jonathan Schöbel authored
Added the allocation part of the implementation of attributes. Also some tests were improved. The functions to add and remove attributes are not implemented, as well as the generation of the html for the attributes. Thats why also test can't really test the attributes as it is not possible to add attributes.
-
Jonathan Schöbel authored
-
- Mar 17, 2023
-
-
Jonathan Schöbel authored
Copy the the contents from one Attr to another and clear the first one.
-
Jonathan Schöbel authored
For every function there is also a static method/function which can perform the same work, but doesn't rely on really having an struct Attr. This is useful for example in an array to manipulate a single element while still using the same code. Also the orginal methods are implemented with the new internal ones themselves.
-
Jonathan Schöbel authored
They are used later, if another internal module wants to use them.
-
Jonathan Schöbel authored
This is used later, if another internal module wants to include the declaration.
-
Jonathan Schöbel authored
When used with care, it is possible to bypass many strdup calls.
-