SDL_ttf icon indicating copy to clipboard operation
SDL_ttf copied to clipboard

Deprecate support of null terminated strings

Open cjwijtmans opened this issue 3 years ago • 3 comments

All the functions in for example TTF_Render* are all null terminated strings. This is bad practice for several reasons, one is security, but another one is that in C++ I would like to map the functions with string_views which are not null terminated in any shape or form. Solution is to provide a character length parameter to all the functions.

cjwijtmans avatar Jun 10 '21 20:06 cjwijtmans

I don't think we want an ABI breaking change simply for handling non null terminated strings ..moreover, all SDL interfaces are C, which make them more compatible.

1bsyl avatar Jun 23 '21 09:06 1bsyl

I don't think we want an ABI breaking change

Deprecation is not breaking.

simply for handling non null terminated strings

"simply"? I have already explained why they are a bad idea.

..moreover, all SDL interfaces are C, which make them more compatible.

Huh? Adding length parameters and deprecating null terminated strings does not make the library any less C or any less compatible. In fact i would say most languages dont natively have null terminated strings but have extra functions to cater to "C compatability"( basic_string<T>::c_str() ) as you call it. So in fact the opposite is true.

cjwijtmans avatar Jun 23 '21 09:06 cjwijtmans

I think it would be a good idea to add functions that take string and length, all other languages besides C that use bindings to SDL have string types with length, and it's even considered unsafe to use nul-terminated strings in C.

ftphikari avatar Jan 12 '22 14:01 ftphikari