edify: Move State.script and State.errmsg to std::string.

This way we kill a few strdup() and free() calls.

Test: 1. recovery_component_test still passes;
2. Applying an update with the new updater works;
3. The error code in a script with abort("E310: xyz") is recorded into
last_install correctly.

Change-Id: Ibda4da5937346e058a0d7cc81764d6f02920010a
This commit is contained in:
Tao Bao
2016-10-03 18:06:46 -07:00
parent 38b923ff6c
commit 59dcb9cbea
5 changed files with 57 additions and 88 deletions
+1 -6
View File
@@ -25,10 +25,7 @@ static void expect(const char* expr_str, const char* expected) {
int error_count;
EXPECT_EQ(parse_string(expr_str, &e, &error_count), 0);
State state;
state.cookie = nullptr;
state.errmsg = nullptr;
state.script = strdup(expr_str);
State state(expr_str, nullptr);
char* result = Evaluate(&state, e);
@@ -38,8 +35,6 @@ static void expect(const char* expr_str, const char* expected) {
EXPECT_STREQ(result, expected);
}
free(state.errmsg);
free(state.script);
free(result);
}