lua-users home
lua-l archive

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


> > I'm surprised that a simple test with very little used memory,
> > Lua is already calling realloc!
> 
> Why ( are you surprised ) ? ( It may be, and given what I have read in
> the manual I suspect is) using realloc for all memory allocations.
> AAMOF a quick grep in the sources show no malloc usages and just a
> single realloc and free ones ( you can do everything with realloc ).

Indeed, Lua uses realloc for all its allocations. According to ISO C99:

  7.20.3.4 The realloc function

  Synopsis
  #include <stdlib.h>
  void *realloc(void *ptr, size_t size);

  [...]
  If ptr is a null pointer, the realloc function behaves like the malloc
  function for the specified size.

-- Roberto