diff options
author | Damien George <damien.p.george@gmail.com> | 2014-02-06 21:11:19 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-02-06 21:11:19 +0000 |
commit | 354d15a964474b0ced060abfbb8f889be8ce8efd (patch) | |
tree | 75fda8eda709fa29bc0d649967119653f4fe71d7 /py/misc.h | |
parent | 64131f321544a28a193e54b1241c8d2efc9ae313 (diff) | |
download | micropython-354d15a964474b0ced060abfbb8f889be8ce8efd.tar.gz micropython-354d15a964474b0ced060abfbb8f889be8ce8efd.zip |
Implement fixed buffer vstrs; use them for import path.
Diffstat (limited to 'py/misc.h')
-rw-r--r-- | py/misc.h | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -68,10 +68,17 @@ typedef struct _vstr_t { int alloc; int len; char *buf; - bool had_error; + struct { + bool had_error : 1; + bool fixed_buf : 1; + }; } vstr_t; +// convenience macro to declare a vstr with a fixed size buffer on the stack +#define VSTR_FIXED(vstr, alloc) vstr_t vstr; char vstr##_buf[(alloc)]; vstr_init_fixed_buf(&vstr, (alloc), vstr##_buf); + void vstr_init(vstr_t *vstr, int alloc); +void vstr_init_fixed_buf(vstr_t *vstr, int alloc, char *buf); void vstr_clear(vstr_t *vstr); vstr_t *vstr_new(void); vstr_t *vstr_new_size(int alloc); @@ -81,7 +88,7 @@ bool vstr_had_error(vstr_t *vstr); char *vstr_str(vstr_t *vstr); int vstr_len(vstr_t *vstr); void vstr_hint_size(vstr_t *vstr, int size); -char *vstr_extend(vstr_t *vstr, int size); +char *vstr_extend(vstr_t *vstr, int size); bool vstr_set_size(vstr_t *vstr, int size); bool vstr_shrink(vstr_t *vstr); char *vstr_add_len(vstr_t *vstr, int len); |