From d13a86674889793f5a6f44e609def3086430494d Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sat, 5 Oct 2019 01:05:04 -0400 Subject: nserver/src/protocol.c: Update sscreate. * nserver/src/protocol.c (sscreate): Flesh it out. Initial version. * nserver/src/protocol.h: Include bstrlib, stats. --- nserver/src/protocol.c | 14 ++++++++++++++ nserver/src/protocol.h | 2 ++ 2 files changed, 16 insertions(+) (limited to 'nserver') diff --git a/nserver/src/protocol.c b/nserver/src/protocol.c index 0d254cd..6963116 100644 --- a/nserver/src/protocol.c +++ b/nserver/src/protocol.c @@ -16,8 +16,22 @@ int ssinit() int sscreate(char *key) { + int rc = 0; + check(ssinit() == 0, "ssinit failed"); + // 1. create bstring from 'key'. + bstring k = bfromcstr(key); + check(k != NULL, "key creation failed"); + + // 2. allocate fresh Stats. + Stats *st = Stats_create(); + check(st != NULL, "stats creation failed"); + + // 3. add to hashmap. + rc = Hashmap_set(hash, k, st); + check(rc == 0, "hashmap set failed"); + return 0; error: return -1; diff --git a/nserver/src/protocol.h b/nserver/src/protocol.h index 22355bd..3d357d9 100644 --- a/nserver/src/protocol.h +++ b/nserver/src/protocol.h @@ -1,7 +1,9 @@ #ifndef _protocol_h #define _protocol_h +#include #include +#include #include int sscreate(char *key); -- cgit v1.2.3