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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user