summaryrefslogtreecommitdiff
path: root/val.h
diff options
context:
space:
mode:
Diffstat (limited to 'val.h')
-rw-r--r--val.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/val.h b/val.h
index 3cf3251..d742c14 100644
--- a/val.h
+++ b/val.h
@@ -8,6 +8,7 @@
typedef struct _val Val;
typedef struct _obj Obj;
+typedef struct _state State;
typedef enum {
@@ -42,11 +43,15 @@ typedef struct {
Obj obj;
size_t len;
uint32_t hash;
- char *b;
+ char *d;
} ObjString;
-ObjString *objstring_copy(char *src, size_t len);
-ObjString *objstring_take(char *src, size_t len);
+// Constructs a new objstring from the given C string,
+// creating its own fresh copy of the data.
+ObjString *objstring_copy(State *S, char *src, size_t len);
+// Constructs a new objstring from the given C string,
+// taking ownership of the provided data.
+ObjString *objstring_take(State *S, char *src, size_t len);
#define IS_NIL(x) (x.ty == NIL)
@@ -61,7 +66,7 @@ ObjString *objstring_take(char *src, size_t len);
#define AS_OBJ(x) (x.as.o)
#define AS_STRING(x) ((ObjString*)AS_OBJ(x))
-#define AS_CSTRING(x) (AS_STRING(x)->b)
+#define AS_CSTRING(x) (AS_STRING(x)->d)
#define VAL_NIL ((Val){.ty=TY_NIL})
#define VAL_NUM(x) ((Val){.ty=TY_NUM, .as.d=(x) })