kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 83a16763c88d833fa299e8c768361b1041d87bb5
parent 105804e32554590e8a09ae87ac53841551c9ee34
Author: Joris Vink <joris@coders.se>
Date:   Mon, 18 Aug 2014 13:57:06 +0200

Always NUL-terminate an asset its data.

This way developers can cast assets to char * without first
having to convert it to a proper C string.

The NUL character is NOT included in the length of the asset.

Diffstat:
src/cli.c | 7+++++++
1 file changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/cli.c b/src/cli.c @@ -618,6 +618,13 @@ cli_build_asset(char *fpath, struct dirent *dp) for (off = 0; off < st.st_size; off++) cli_file_writef(out, "0x%02x,", *d++); + /* + * Always NUL-terminate the asset, even if this NUL is not included in + * the actual length. This way assets can be cast to char * without + * any additional thinking for the developer. + */ + cli_file_writef(out, "0x00"); + /* Add the meta data. */ cli_file_writef(out, "};\n\n"); cli_file_writef(out, "u_int32_t asset_len_%s_%s = %" PRIu32 ";\n",