diff options
author | Jeremy Sowden <jeremy@azazel.net> | 2021-11-30 10:55:34 +0000 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2021-11-30 20:55:17 +0100 |
commit | 721aa6f74f17f56dd82873aefffb2d6683918b79 (patch) | |
tree | 136aa49ccd4120647dd0c752d7585475691ce12a /output/mysql/ulogd_output_MYSQL.c | |
parent | c3176a3b5c129cbb94f7ff3f18b03d81f847cef3 (diff) |
Replace malloc+memset with calloc
There are a number of places where we `malloc` some memory and then
`memset` it to zero. Use `calloc` instead.
Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'output/mysql/ulogd_output_MYSQL.c')
-rw-r--r-- | output/mysql/ulogd_output_MYSQL.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/output/mysql/ulogd_output_MYSQL.c b/output/mysql/ulogd_output_MYSQL.c index 643320c..66151fe 100644 --- a/output/mysql/ulogd_output_MYSQL.c +++ b/output/mysql/ulogd_output_MYSQL.c @@ -127,16 +127,12 @@ static int get_columns_mysql(struct ulogd_pluginstance *upi) upi->input.num_keys = mysql_num_fields(result); ulogd_log(ULOGD_DEBUG, "%u fields in table\n", upi->input.num_keys); - upi->input.keys = malloc(sizeof(struct ulogd_key) * - upi->input.num_keys); + upi->input.keys = calloc(upi->input.num_keys, sizeof(*upi->input.keys)); if (!upi->input.keys) { upi->input.num_keys = 0; ulogd_log(ULOGD_ERROR, "ENOMEM\n"); return -ENOMEM; } - - memset(upi->input.keys, 0, sizeof(struct ulogd_key) * - upi->input.num_keys); for (i = 0; (field = mysql_fetch_field(result)); i++) { char buf[ULOGD_MAX_KEYLEN+1]; |