sepisoad / jurl Goto Github PK
View Code? Open in Web Editor NEWjanet wrapper around libcurl
License: GNU General Public License v3.0
janet wrapper around libcurl
License: GNU General Public License v3.0
Browsing through the code, thought I would answer some questions about the Janet API
easy_setopt
, use -1 in janet_arity
to ignore min or max arity. (janet_arity(argc, 2, 1000)
becomes janet_arity(argc, 2, -1)
)opts_set
has some issues when called from easy_setopt
. The argv
pointer is only temporary, so leaving pointers to it for callback functions is not going to work often. It seems to work in the test because that part of the stack is never overwritten, but in most programs it won't work.A really simple fix (that will leak memory, but so be it) is to put arguments in a tuple, reference it so it will not be collected, and then use that instead of argv.
easy.c - old code:
for (int32_t idx = 1; idx < argc; idx+=2){
opts_set(curl, argv + idx, argv + idx + 1);
}
easy.c - patched
const Janet *argv2 = janet_tuple_n(argv, argc);
janet_gcroot(janet_wrap_tuple(argv2));
for (int32_t idx = 1; idx < argc; idx+=2){
opts_set(curl, argv2 + idx, argv2 + idx + 1);
}
This won't invoke use after free issues, but the tuple argv2 will never be freed. Using an abstract type would be a good solution that would not leak memory.
Please would you consider to make simple format, where you remove whitespaces from the end of the lines, or even to start to use some formatting utility like astyle?
In my C projects, I am using the default settings for astyle, which is also the one @bakpakin uses for his C code.
It would really help to contribute to this project to me and others :-).
If you like to I will be more than happy to do it my self.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.