GithubHelp home page GithubHelp logo

jurl's People

Contributors

andrewchambers avatar bakpakin avatar disruptek avatar pepe avatar raphm avatar sepisoad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

jurl's Issues

Formatting the c source

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.

Janet API comments

Browsing through the code, thought I would answer some questions about the Janet API

  • in easy_setopt, use -1 in janet_arity to ignore min or max arity. (janet_arity(argc, 2, 1000) becomes janet_arity(argc, 2, -1))
  • In opts.c, the function 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.