Implement strings the way Go itself does

This makes string slicing cheap.
This commit is contained in:
Ayke van Laethem
2018-04-14 19:24:21 +02:00
parent 7cc2301621
commit 60a01a43a3
3 changed files with 10 additions and 15 deletions
+2 -2
View File
@@ -4,8 +4,8 @@
#include <stdint.h>
typedef struct {
uint32_t len; // TODO: size_t (or, let max string size depend on target/flag)
uint8_t buf[]; // variable size
uint32_t len; // TODO: size_t (or, let max string size depend on target/flag)
uint8_t *buf; // points to string buffer itself
} string_t;
typedef int32_t intgo_t; // may be 64-bit