Repository navigation
Add a runtime for C++, a header over the one for C - #23
Merged
Merged
Conversation
asnkit_map_set() and asnkit_value_new_choice() kept the pointer to the name they were given rather than a copy of it. A program that gave a name in a buffer it then freed or used again had a value with a name that was freed or changed, and reading or encoding it read freed memory. Names that are string literals were not affected. It was so from 2.0.0-rc1 on. tests/api.c gives the names in a buffer that it then writes over. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
include/asnkitrt.hpp is for C++17 and later, and has no library of its own: it is only a header over asnkitrt.h. asnkit::spec and asnkit::value free what they hold, a value is copied deeply and moved cheaply, what an accessor gives is a view (asnkit::value_view, std::string_view, asnkit::bytes_view), and an error is thrown as an asnkit::error, of a class for each status. The error of a range is asnkit::asn_range_error, so as not to be std::range_error where both namespaces are used. asnkit_last_error_status() is new in asnkitrt.h: the status of the last error of the thread, which tells which error a function that returned a NULL handle had. The header for C++ throws by it. tests/c.rs compiles and runs tests/api.cpp and examples/question.cpp as C++17 with -Wall -Wextra -Werror -pedantic, as it does the C, and checks the header as C++20 and C++23. tests/header.rs holds asnkitrt.hpp to use every function of asnkitrt.h. The job runtime-c links the example of C++ with the static library and runs it. The READMEs, the documentation and the skill tell of it. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
packages/asnkitrt-c/include/asnkitrt.hppis the runtime for C++17 and later: only a header, overasnkitrt.hand the same library. In two commits.Copy the names of members and alternatives in the runtime for C
asnkit_map_set()andasnkit_value_new_choice()kept the pointer to the name they were given rather than a copy of it, so a name in a buffer that was then freed or used again left a value that read freed memory. It was so from 2.0.0-rc1 on, and names that are string literals were not affected. The temporaries of C++ are what showed it.tests/api.cgives the names in a buffer that it then writes over.Add a runtime for C++, a header over the one for C
asnkit::specandasnkit::valuefree what they hold. A value is copied deeply and moved cheaply, and what an accessor gives is a view:asnkit::value_view,std::string_view,asnkit::bytes_view.asnkit::error, of a class for each status, andasnkit::decode_errorhas the offset. The error of a range isasnkit::asn_range_error, so as not to bestd::range_errorwhere both namespaces are used.asnkit_last_error_status(): new inasnkitrt.h, the status of the last error of the thread. It tells which error a function that returned aNULLhandle had, and the header for C++ throws by it.tests/c.rscompiles and runstests/api.cppandexamples/question.cppas C++17 with-Wall -Wextra -Werror -pedantic, and checks the header as C++20 and C++23.tests/header.rsholdsasnkitrt.hppto use every function ofasnkitrt.h. The jobruntime-clinks the example of C++ with the static library and runs it.docs/,CHANGELOG.mdand the skill tell of it.Checks
cargo fmt --all -- --check,cargo clippy -p asnkitrt-c --all-targets -- -D warningsandcargo test -p asnkitrt-cpass with Apple clang, andmkdocs build --strictpasses.-O2, and-Wshadow -Wconversion -Wold-style-cast -Wuseless-cast -Wnull-dereference -Wduplicated-cond -Wlogical-opwith no diagnostics.range_errorwas namedasn_range_error.leaks --atExiton macOS: nothing.MSVC has not compiled it. Text as
char8_tand bytes asstd::byteare not taken.