summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nserver/src/protocol.c14
-rw-r--r--nserver/src/protocol.h2
2 files changed, 16 insertions, 0 deletions
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 <bstrlib.h>
#include <hashmap.h>
+#include <stats.h>
#include <dbg.h>
int sscreate(char *key);