I saw the link to this project on hacker news, it looks interesting. One thing I noticed was that in grow() it has
// TYPE1 -> TYPE4
RELOC(4)
memcpy (newdata, DATA(newhead, TYPE1), dims.len+1);
the result of memcpy() is undefined when the source and destination overlap, this should use memmove() instead. One a related note the code to grow a string seems to be duplicated in a different form in resize(), perhaps that could call grow() instead.
I saw the link to this project on hacker news, it looks interesting. One thing I noticed was that in
grow()it hasthe result of
memcpy()is undefined when the source and destination overlap, this should usememmove()instead. One a related note the code to grow a string seems to be duplicated in a different form inresize(), perhaps that could callgrow()instead.