Re:Facil.io: A micro-framework for C web applications
by polotics on Saturday January 26, 2019 @04:01AM
(#19005543)
The example has functions' string parameters and separate parameters for the string's length. Is this really necessary what happens if the declared length is more than the actual length?
[ Parent
| on HN ]
Re:Facil.io: A micro-framework for C web applications
by bowild on Thursday January 31, 2019 @12:53PM
(#19046899)
Actually, it's to allow for non-NUL terminated strings.
A good example is when using a String supplied by a scripting language such as Ruby or JavaScript.
Normally, you might need to copy the string to add a NUL byte, or request that the scripting engine provide a NUL terminated string (which might result in the same action performed).
Using this optional approach, a potential copy of the data can be avoided.
Re:Facil.io: A micro-framework for C web applications
by tom_mellior on Saturday January 26, 2019 @04:06AM
(#19005556)
Knowing nothing about this, I would guess that this is to allow sending binary data that contains embedded null bytes?
Though I guess it would be good to have nicer wrappers for the common case where you do only send text.
Re:Facil.io: A micro-framework for C web applications
by loeg on Saturday January 26, 2019 @12:33PM
(#19007272)
Probably they use length-prefixed strings internally (which is probably a requirement for taking a C web framework seriously), but allow C nul-terminated strings at the API boundary for convenience of use.
Re:Facil.io: A micro-framework for C web applications
by pantalaimon on Saturday January 26, 2019 @07:11AM
(#19005981)
No it is not necessary.
If no length is given, the string is assumed to be NULL-terminated.
It's a bit unfortunate that they use two code paths for that which are basically just copy & paste.
https://github.com/boazsegev/facil.io/blob/master/lib/facil/...