From 15d764a80b204e708dd13f45f3f1a5a66bd1730d Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Sun, 25 Sep 2011 17:37:17 +1100 Subject: [PATCH] * code cleanup --- src/torrent2json.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/torrent2json.c b/src/torrent2json.c index c145813..7d16828 100644 --- a/src/torrent2json.c +++ b/src/torrent2json.c @@ -67,15 +67,15 @@ get_string(int chr) len *= 10, len += c - '0'; /* 'c' now should contain ':' */ - if ((buf = malloc(sizeof(char) * len + 1)) == NULL) + if ((buf = malloc(sizeof(char) * (len + 1))) == NULL) { fprintf(stderr, "Can't allocate memory, exiting.\n"); exit(EXIT_FAILURE); } - memset(buf, '\0', len + 1); + memset(buf, '\0', sizeof(char) * (len + 1)); for (i = 0; i < len; i++) - *(buf + i * sizeof(char)) = fgetc(in); + buf[i] = fgetc(in); yajl_gen_string(gen, buf, len);