Brent Dax wrote:
Leopold Toetsch:
# - string_set() is gone, highly (WRT malloc) illegal reusage # of existing # string headers - and unnecessary IMHO
I specifically asked for and received permission from Dan for this.
It's designed to remove the need to pass in
pointers-to-pointers-to-headers in functions with string_substr-like
semantics, allowing you to allocate a header *once* and reuse it instead
of potentially reallocating dozens of times.
It's totally sane with the standard copying allocator. But the malloc allocator tracks resources (i.e. strings bufstart) only via the header. So, when you reuse the header, the old bufstart which was there before is unmanaged and leaks.
So this was ok til now, when considering: we have a leak free interpreter now and it runs with --gc=malloc.
BTW by e.g. not adding char by char of the sprintf format, I did already save a lot more headers, then above hack could yield. Another improvement would be: in uint_to_str allocate string of needed length, put chars in in reverse order, then reverse the string.
leo