> On Wed, Jan 28, 2026, at 8:13 PM, Jose E. Marchesi wrote: >> Hi Pietro. >> Thanks for the patch. >> >>> _libga68_u32_to_u8 called free on the result buffer on error, but the >>> buffer is allocated by the GC, so calling free on it is incorrect. >> >> But if LIBGA68_WITH_GC is not defined then _libga68_malloc_leaf used the >> regular malloc, right? So the memory needs to be free or we will be >> leaking memory.. > > If libga68 is built without the gc we always leak memory anyway.
Ideally, only if heap generators are explicitly used in the program. In practice we are at this point using the heap for certain constructs (like trimming of multiples) because we are lacking the necessary optimizations in the front-end. But the goal is to avoid heap allocation unless explicitly requested so by the user.. >> Wouldn't it be better to make these functions always use >> _libga68_malloc_internal and _libga68_malloc_free instead? > > It would. I'll give it a stab at using malloc_internal in u32_to_u8 > and freeing in the callers. Thanks!
