Coder Social home page Coder Social logo

Remove variable length arrays about nextvi HOT 14 CLOSED

kyx0r avatar kyx0r commented on August 25, 2024 1
Remove variable length arrays

from nextvi.

Comments (14)

kyx0r avatar kyx0r commented on August 25, 2024

Not efficient, but possible. replacing VLAs with malloc is fairly straightforward process.

from nextvi.

kyx0r avatar kyx0r commented on August 25, 2024

Static arrays probably won't work, unless you be willing to make some assumptions and reserve large blocks of memory.

from nextvi.

adriangrigore avatar adriangrigore commented on August 25, 2024

So how would you go about it? I can migrate to malloc, but not sure about sizes for static arrays. Migrate all VLAs to malloc-ed ones?

from nextvi.

adriangrigore avatar adriangrigore commented on August 25, 2024

Here's how nextvi looks on 9front nextvi on 9front

from nextvi.

kyx0r avatar kyx0r commented on August 25, 2024

How did you get it to compile?

Actually, changing to static array is rather trivial. Just make 1 global char array with size of 0.5MB-1MB and reference it everywhere its needed. Basically we simulate our own stack. The only case where this would not work is multithreaded code, which does exists if you use the threaded_search.patch. Its optional however.

from nextvi.

adriangrigore avatar adriangrigore commented on August 25, 2024

How did you get it to compile?

I just created static arrays with large sizes, but opened the issue because I was unsure about the sizes.

Actually, changing to static array is rather trivial. Just make 1 global char array with size of 0.5MB-1MB and reference it everywhere its needed. Basically we simulate our own stack. The only case where this would not work is multithreaded code, which does exists if you use the threaded_search.patch. Its optional however.

I might switch to multi threaded code because I'm considering adding mouse support. Where can I find the threaded_search patch?

from nextvi.

adriangrigore avatar adriangrigore commented on August 25, 2024

Any other tips for porting to a multi threaded environment?

from nextvi.

kyx0r avatar kyx0r commented on August 25, 2024

How did you get it to compile?

I just created static arrays with large sizes, but opened the issue because I was unsure about the sizes.

Ahh, in that case I can tell you that regex would need the most memory.

char nsubs[prog->sub];

nsubs can get quite large.

I might switch to multi threaded code because I'm considering adding mouse support. Where can I find the threaded_search patch?

https://github.com/kyx0r/nextvi/tree/patches

Not sure if multithreading is actually required for mouse though. Because all that mouse is just reading keycodes from the terminal. Not difference from keyboard. Only question if the terminal a universal format for this.

from nextvi.

adriangrigore avatar adriangrigore commented on August 25, 2024

The terminal is not in a standard format. I doesn't support escape codes. This is more of a GUI application than a TUI application in 9front. From what I understand, mouse support requires a multi threaded environment: https://9fans.github.io/plan9port/man/man3/thread.html.
https://wiki.9front.org/programming-gui

This is what term.c would look like on 9front (wip) http://okturing.com/src/17118/body.

from nextvi.

kyx0r avatar kyx0r commented on August 25, 2024

Any other tips for porting to a multi threaded environment?

I think regex is the most problematic where just making a static array may not cut it. In that case you can add pointers in the rcode structure and malloc them at reg_comp. Then just use those pointers in re_pikevm.

from nextvi.

kyx0r avatar kyx0r commented on August 25, 2024

Hi, any progress on this? It would be nice to add an optional patch that removes VLA for systems that may benefit from it.

from nextvi.

Related Issues (20)

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.