nserver

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

commit d13a86674889793f5a6f44e609def3086430494d
parent 63a4b5015fcbfcc54958a755993db19337132ed1
Author: rsiddharth <s@ricketyspace.net>
Date:   Sat,  5 Oct 2019 01:05:04 -0400

nserver/src/protocol.c: Update sscreate.

* nserver/src/protocol.c (sscreate): Flesh it out. Initial version.
* nserver/src/protocol.h: Include bstrlib, stats.

Diffstat:
nserver/src/protocol.c | 14++++++++++++++
nserver/src/protocol.h | 2++
2 files changed, 16 insertions(+), 0 deletions(-)

diff --git 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 @@ -1,7 +1,9 @@ #ifndef _protocol_h #define _protocol_h +#include <bstrlib.h> #include <hashmap.h> +#include <stats.h> #include <dbg.h> int sscreate(char *key);