lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> I noticed that in order to free memory, it basically calls realloc with 0 as the new size. Is this something musl doesn't handle well?

Lua does not do that. It does call its own allocator function with
size==0, but its own allocator function is not 'realloc'. In standard
Lua, the allocator function looks like this:

static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
  (void)ud; (void)osize;  /* not used */
  if (nsize == 0) {
    free(ptr);
    return NULL;
  }
  else
    return realloc(ptr, nsize);
}

So, if size==0, it calls 'free', not 'realloc'.

-- Roberto