diff options
Diffstat (limited to 'val.c')
-rw-r--r-- | val.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -2,15 +2,27 @@ #include <string.h> #include "val.h" #include "mem.h" +#include "ht.h" -ObjString *objstring_new(char *src, size_t len) { +ObjString *objstring_copy(char *src, size_t len) { char *d = NEW_ARR(char, 1+len); memcpy(d, src, len); d[len] = '\0'; ObjString *o = NEW_OBJ(ObjString, OTY_STRING); o->len = len; o->b = d; + o->hash = hash(d, len); + + return o; +} + +ObjString *objstring_take(char *src, size_t len) { + ObjString *o = NEW_OBJ(ObjString, OTY_STRING); + o->len = len; + o->b = src; + o->hash = hash(src, len); + return o; } |