Refactor l2vm

This commit is contained in:
2021-04-07 22:24:33 +03:00
parent 8f694a0bca
commit c74ea3b417
25 changed files with 653 additions and 285 deletions
+6 -1
View File
@@ -1,16 +1,21 @@
#include "error.h"
#include "vmstring.h"
#include <string.h>
#include <stdlib.h>
void vm_string_init(struct vm_string *str, const char *text) {
int vm_string_init(struct vm_string *str, const char *text) {
if (text && *text) {
str->data = strdup(text);
if (!str->data) {
return -ERR_OUT_OF_MEMORY;
}
str->len = strlen(text);
str->cap = str->len + 1;
} else {
vm_string_empty(str);
}
return 0;
}
void vm_string_empty(struct vm_string *str) {