5 ms·
I don't love this trick. To get this to work, they had to typedef the string type to char*, which means the API will also accept any normal string and probably
by stkdump 7y ago
I don't love this trick. To get this to work, they had to typedef the string type to char*, which means the API will also accept any normal string and probably crash at runtime. So to get this little convenience feature, type safety was sacrificed.
- tmp0258 7y agoSeems to me that it would also prevent tools like the address sanitizer and valgrind from detecting some invalid memory accesses (corresponding to negative indexes). A "more conventional" string library [1] might be safer. [1] for example: https://github.com/websnarf/bstrlib/blob/master/bstrlib.txt https://github.com/websnarf/bstrlib/blob/master/bstrlib.txt