Remix.run Logo
PaulHoule 5 days ago

So you're saying the runtime mallocs the pointer to the closure and it's your responsibility to free it when you don't need it anymore?

ori_b 5 days ago | parent [-]

Kinda. Here's an example:

     void
     mkclosure(int x)
     {
         int x;
         void fn(void){ return x + 1; }
         return fnheapify(fn);
     }

     void
     useclosure(void)
     {
         void (^fn)(void) = mkclosure(42);
         fn();
         fnfree(fn);
     }