nserver

nihilistic stats server
Log | Files | Refs | README | LICENSE

commit 436a0beb7f1191f4237732ad60383e5253674c02
parent d5f23304ee49697df888e54ce7e54ef0823c098c
Author: rsiddharth <s@ricketyspace.net>
Date:   Sun, 19 Apr 2020 01:12:07 -0400

protocol.c: Update ssstore.

* src/protocol.c (ssstore): Clean up st_str.

Diffstat:
src/protocol.c | 10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/protocol.c b/src/protocol.c @@ -242,6 +242,8 @@ char *sslist() int ssstore(char *key) { + char *st_str = NULL; + check(key != NULL && strlen(key) > 0, "key invalid"); check(tst != NULL, "tstree not initialized"); @@ -253,15 +255,21 @@ int ssstore(char *key) check(rec->deleted != 1, "record was deleted"); // 2. stringify the stats. - char *st_str = Stats_stringify(rec->st); + st_str = Stats_stringify(rec->st); check(st_str != NULL, "stats stringify failed"); // 3. store stats in db. int rc = db_store(key, st_str); check(rc == 0, "db store failed"); + // 4. cleanup. + free(st_str); + return 0; error: + if (st_str) { + free(st_str); + } return -1; }