Automatic garbage collection in C is possible with libraries like libgc, but with allocppx.pl, you can just preprocess your file into generating heaps, and these heaps can be used for memory allocation. The type of GC is used, mark and sweep + reference counting. Every memory allocation MAY have a trace, and this trace can be used to ‘refget’ and ‘refunget’. Heap items that are NULL or have 0 refs are collected via mark and sweep.

The generated code is very readable, you can just look at it to get a clue. However, this Perl document is annotated with POD so you can view it in man pages etc. I have submitted an ASCII render of the manpage in Gist.

I hope you enjoy this.

  • solrize@lemmy.world
    link
    fedilink
    arrow-up
    4
    arrow-down
    8
    ·
    7 months ago

    It’s cool that someone is still using perl. It’s sad that anyone is still using C. (Yes I still use it myself, but…).

    • ChubakPDP11+TakeWithGrainOfSalt@programming.devOP
      link
      fedilink
      arrow-up
      2
      arrow-down
      14
      ·
      7 months ago

      Why ‘exactly’ is it bad that people are still using C, a language with 4 decades of toolchain and library build-up, instead of a shitlang like Rust that is mainly used to create garbage webapps?

      • lolcatnip@reddthat.com
        link
        fedilink
        English
        arrow-up
        10
        arrow-down
        2
        ·
        edit-2
        7 months ago

        Ooooh, luddism is so edgy!

        And no, Rust is not primarily used to generate web apps, shitty or otherwise. You’re thinking of JavaScript.

        • ChubakPDP11+TakeWithGrainOfSalt@programming.devOP
          link
          fedilink
          arrow-up
          2
          arrow-down
          9
          ·
          7 months ago

          Cool, as I just said, Rust is more of a ‘fandom’ than a ‘compiler’ really, it’s also not much of a ‘language’. I use C because it’s standardized by ISO, not some basement-dwelling incels who keep RFCi’ing their ideas instead of implementing it their own.

      • FizzyOrange@programming.dev
        link
        fedilink
        arrow-up
        6
        ·
        7 months ago

        Wow, I would love to understand what leads to such insane views. Like, did Rust kill your father or something?

        I’m actually serious, why do you have such love for a bad (by modern standards) language like C and such hatred for a great language like Rust?