Refactor l2vm
This commit is contained in:
+6
-1
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user