mirror of
https://github.com/micropython/micropython.git
synced 2026-01-04 19:20:22 +01:00
py: Change vstr so that it doesn't null terminate buffer by default.
This cleans up vstr so that it's a pure "variable buffer", and the user can decide whether they need to add a terminating null byte. In most places where vstr is used, the vstr did not need to be null terminated and so this patch saves code size, a tiny bit of RAM, and makes vstr usage more efficient. When null termination is needed it must be done explicitly using vstr_null_terminate.
This commit is contained in:
@@ -145,6 +145,7 @@ size_t vstr_len(vstr_t *vstr);
|
||||
void vstr_hint_size(vstr_t *vstr, size_t size);
|
||||
char *vstr_extend(vstr_t *vstr, size_t size);
|
||||
char *vstr_add_len(vstr_t *vstr, size_t len);
|
||||
void vstr_null_terminate(vstr_t *vstr);
|
||||
void vstr_add_byte(vstr_t *vstr, byte v);
|
||||
void vstr_add_char(vstr_t *vstr, unichar chr);
|
||||
void vstr_add_str(vstr_t *vstr, const char *str);
|
||||
|
||||
Reference in New Issue
Block a user