- Mar 20, 2023
-
-
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.
-
Jonathan Schöbel authored
When used with care, it is possible to bypass many strdup calls. To also save the instructions for the call, which are a lot of overhead now, link time optimization is turned on. (-flto)
-
Jonathan Schöbel authored
-
Jonathan Schöbel authored
-
Jonathan Schöbel authored
Sometimes a copy is useful.
-
Jonathan Schöbel authored
As usual it should be also possible to bypass calls to strdup, while also taking care.
-
Jonathan Schöbel authored
The structure SH_Attr implements an HTML Attribute.
-
Jonathan Schöbel authored
The function get_alloc_size was renamed to get_child_alloc_size as the attributes will need another function.
-
- Mar 16, 2023
-
-
Jonathan Schöbel authored
Various remove methods were added, which are all implemented by an static method, analog to the last commit.
-
Jonathan Schöbel authored
The single method (formerly SH_NodeFragment_append_child) to add a child at the end of the child list was replaced, by a bunch of methods to insert a child at the beginning (SH_NodeFragment_prepend_child), at the end (SH_NodeFragment_append_child), at a specific position (SH_NodeFragment_insert_child) and directly before (SH_NodeFragment_insert_child_before) or after another child (SH_NodeFragment_insert_child_after). All these methods are implemented by a single internal one (insert_child), as there isn't really much difference in inserting one or the other way. But this internal method doesn't check whether this insertion request is actually doable, to save overhead as not every insertion method requires this check. This is done by the respective method. However if the check is not done correctly the internal method will attempt to write at not allocated space, which will hopefully result in a segfault. The child list is implemented as an array. To reduce the overhead to realloc calls, the array is allocated in chunks of childs. The calculation how many has to be allocated is done by another static method and determined by the macro CHILD_CHUNK. This is set to 5, which is just a guess. It should be somewhere around the average number of childs per html element, to reduce unused overhead. Also some predicates (SH_NodeFragment_is_parent, SH_NodeFragment_is_ancestor) were added to check whether a relationship exists between to nodes, thus whether they are linked through one or multiple levels. These functions could replace the old ones (SH_NodeFragment_is_child, SH_NodeFragment_is_descendant) semantically. Furthermore they are more efficient as this is now possible to check over the parent pointer. The internal insert method also uses these methods to check whether the child node is actually a parent of the parent node, which would result in errors later one. The old test is now obsolete but remained, as it is not bad to test more.
-
- Mar 13, 2023
-
-
Jonathan Schöbel authored
Removed some unnecessary type casts. Added some forgotten calls to free.
-
Jonathan Schöbel authored
Every fragment has a parent now, this is useful for both traversing the tree and checking for cycles when a node is added, which would cause problems, like freeing things twice or similar nice bugs. Both wouldn't be possible otherwise. These features are not implemented yet.
-
Jonathan Schöbel authored
The library provides a way to directly access the tag in a read-only way, which saves an call to strdup. This is useful if only reading is necessary , but needs special care by developers, as it is neither allowed to modify it nor to free it. Disregarding this will lead to a segfault in the best, and to silent data corruption and security bugs in the worst case.
-
- Jan 09, 2023
-
-
Jonathan Schöbel authored
-
Jonathan Schöbel authored
-
- Jan 06, 2023
-
-
Jonathan Schöbel authored
-
Jonathan Schöbel authored
Symbols preceded by an underscore are reserved for future introductions by the c standard/library.
-
Jonathan Schöbel authored
-
Jonathan Schöbel authored
-
- Jan 05, 2023
-
-
Jonathan Schöbel authored
-
Jonathan Schöbel authored
-
Jonathan Schöbel authored
-
Jonathan Schöbel authored
-
Jonathan Schöbel authored
-
- Jan 04, 2023
-
-
Jonathan Schöbel authored
An array index should be of size_t instead of unsigned int.
-
Jonathan Schöbel authored
Internal struct definitions shouldn't be exported by header files.
-
Jonathan Schöbel authored
-
Jonathan Schöbel authored
-
Jonathan Schöbel authored
The validator was used to check that every created tag is validate. However I now think that validation should take place at a later time, so it is not mandatory. Thus developing the validator is now discontinued.
-
- Nov 24, 2022
-
-
Jonathan Schöbel authored
Often it is needed to iterate over the tags. So this was moved to a macro to reduce code duplication.
-
- Nov 23, 2022
-
-
Jonathan Schöbel authored
Copying a Validator could be useful if multiple html versions are to be supported. Another use case is a blacklist XSS-Scanner.
-
Jonathan Schöbel authored
A registered tag can be deregistered by calling SH_Validator_deregister. The data is removed, but the space is not deallocated, if it is not at the end. This prevents copying data on removal and saves expensive calls to realloc. Instead the empty space is added to the list of free blocks, which allows to refill these spaces, if a new tag is being registered. The space is finally deallocated, if the validator is being deallocated or the tag written in the last block is removed. In this case, heavy iteration is performed, as the list of free blocks is not ordered. The next last tag at that time is determined by iterating over the list of free blocks until some it is not found. Note that even if there can be a lot of gaps in between, the Validator will not allocate more space until all these gaps are refilled when a new tag is registered, thus new space is only being allocated, if there is really not enough space left. Due to the 4 nested loops, there was an issue related to the 72(80)-column rule. It can't be abided without severely impacting the readability of the code.
-
- Nov 17, 2022
-
-
Jonathan Schöbel authored
Source code regarding tags are exported to validator_tag.c and validator_tag.h for better separation and integration of new features.
-
- Nov 16, 2022
-
-
Jonathan Schöbel authored
The Validator saves the tags as an array. Now also another information is added, which slots aren't used currently to spare expensive calls to realloc. This led to a mere reimplementation of the functions. Tags can't be deleted by now, but the adding function supports reusing empty slots. Also the reading functions have to determine, whether a slot can be read or is empty. The tests were adjusted, but are buggy, so they should be rewritten in the future. Additionaly some annotations for splint were added.
-
- Nov 15, 2022
-
-
Jonathan Schöbel authored
Instead of the trivial structure SH_Error, SH_Status is used. The name was chosen, because error/status is set independently whether an error has occurred. Beside the error type, it also contains the associated errno and an error message. The error message is also printed, when it is set. Generating error messages with variadic arguments is now also supported. There are also macros to check for a set status. The exception handling was removed for the *_free methods, because they can't fail predictably during runtime. Unfortunately the compiler reports, that inside the macro set_status printf may be called with NULL [printf (NULL)], although, this is explicitly debarred.
-