diff options
author | Jeremy Sowden <jeremy@azazel.net> | 2021-11-30 10:55:48 +0000 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2022-01-03 15:00:49 +0100 |
commit | 53d669d95c94aab4366b8fe9544d61369aa384b5 (patch) | |
tree | 5cb0680291cd6f3823dd3b32744615b3609a07f7 /src | |
parent | 1d9fd9d64b17b48dd0b38bdebb7086c88a649e1b (diff) |
output: SQLITE3: improve formatting of insert statement
`sqlite3_createstmt` contains a variable `stmt_pos` which points to the
end of the SQL already written, where the next chunk should be appended.
Currently, this is assigned after every write:
sprintf(stmt_pos, ...);
stmt_pos = priv->stmt + strlen(priv->stmt);
However, since `sprintf` returns the number of bytes written, increment
`stmt_pos` by the return-value of `sprintf` in order to avoid the
repeated `strlen` calls.
Pablo mangled this original patch to add this chunk at the end of this
patch (originally submitted as a conversion to use strcpy).
+ for (i = 0; i < cols - 1; i++)
+ stmt_pos += sprintf(stmt_pos, "?,");
Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
0 files changed, 0 insertions, 0 deletions