aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Bao2016-10-03 20:06:46 -0500
committerTao Bao2016-10-04 16:24:32 -0500
commit59dcb9cbea8fb70ab933fd10d35582b08cd13f37 (patch)
tree64a8c1e78aa282460aebf39d3f4147d00ffa0fcc /edify/expr.h
parent38b923ff6caafbb92935e7d13640d6b05f2a7466 (diff)
downloadplatform-bootable-recovery-59dcb9cbea8fb70ab933fd10d35582b08cd13f37.tar.gz
platform-bootable-recovery-59dcb9cbea8fb70ab933fd10d35582b08cd13f37.tar.xz
platform-bootable-recovery-59dcb9cbea8fb70ab933fd10d35582b08cd13f37.zip
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
Diffstat (limited to 'edify/expr.h')
-rw-r--r--edify/expr.h22
1 files changed, 11 insertions, 11 deletions
diff --git a/edify/expr.h b/edify/expr.h
index 88634799..f045d938 100644
--- a/edify/expr.h
+++ b/edify/expr.h
@@ -18,6 +18,7 @@
18#define _EXPRESSION_H 18#define _EXPRESSION_H
19 19
20#include <unistd.h> 20#include <unistd.h>
21#include <string>
21 22
22#include "error_code.h" 23#include "error_code.h"
23#include "yydefs.h" 24#include "yydefs.h"
@@ -26,20 +27,20 @@
26 27
27typedef struct Expr Expr; 28typedef struct Expr Expr;
28 29
29typedef struct { 30struct State {
31 State(const std::string& script, void* cookie);
32
33 // The source of the original script.
34 const std::string& script;
35
30 // Optional pointer to app-specific data; the core of edify never 36 // Optional pointer to app-specific data; the core of edify never
31 // uses this value. 37 // uses this value.
32 void* cookie; 38 void* cookie;
33 39
34 // The source of the original script. Must be NULL-terminated,
35 // and in writable memory (Evaluate may make temporary changes to
36 // it but will restore it when done).
37 char* script;
38
39 // The error message (if any) returned if the evaluation aborts. 40 // The error message (if any) returned if the evaluation aborts.
40 // Should be NULL initially, will be either NULL or a malloc'd 41 // Should be empty initially, will be either empty or a string that
41 // pointer after Evaluate() returns. 42 // Evaluate() returns.
42 char* errmsg; 43 std::string errmsg;
43 44
44 // error code indicates the type of failure (e.g. failure to update system image) 45 // error code indicates the type of failure (e.g. failure to update system image)
45 // during the OTA process. 46 // during the OTA process.
@@ -50,8 +51,7 @@ typedef struct {
50 CauseCode cause_code = kNoCause; 51 CauseCode cause_code = kNoCause;
51 52
52 bool is_retry = false; 53 bool is_retry = false;
53 54};
54} State;
55 55
56#define VAL_STRING 1 // data will be NULL-terminated; size doesn't count null 56#define VAL_STRING 1 // data will be NULL-terminated; size doesn't count null
57#define VAL_BLOB 2 57#define VAL_BLOB 2