Skip to content

Commit

Permalink
Merge pull request #281 from trilitech/palmer@functori@optimize-struct
Browse files Browse the repository at this point in the history
Reduce the global struct size
  • Loading branch information
spalmer25 authored Sep 12, 2024
2 parents 12848ed + a604f8b commit a907073
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/src/apdu_sign.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ typedef struct {
union {
/// @brief clear signing state info.
struct {
size_t total_length;
tz_parser_state parser_state;
size_t total_length;
uint8_t last_field_index;
bool received_msg;
} clear;
Expand Down
2 changes: 1 addition & 1 deletion app/src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ typedef enum {
*/
typedef struct {
/* State */
main_step_t step; /// Current operational state of app.
tz_ui_stream_t stream; /// UX and display related information
bip32_path_with_curve_t path_with_curve; /// Derivation path
union {
Expand Down Expand Up @@ -119,6 +118,7 @@ typedef struct {
char error_code[ERROR_CODE_SIZE]; /// Error codes to be displayed in
/// blindsigning.
#endif
main_step_t step; /// Current operational state of app.
} globals_t;

/* Settings */
Expand Down
8 changes: 4 additions & 4 deletions app/src/parser/parser_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ typedef struct {
tz_parser_regs regs; /// parser register

/// common fields to communicate with caller
tz_parser_result errno; /// current parser result
struct {
char field_name[TZ_FIELD_NAME_SIZE]; /// name of the last field
/// parsed
Expand All @@ -100,14 +99,15 @@ typedef struct {
} field_info; /// information of the last field parsed
// common singleton buffers
int ofs; /// offset for the parser
/// input type specific state
tz_micheline_state micheline; /// micheline parser state
tz_operation_state operation; /// operation parser state
struct {
tz_num_parser_buffer num; /// number parser buffer
uint8_t capture[TZ_CAPTURE_BUFFER_SIZE]; /// capture buffer is used
/// to store string values
} buffers;
/// input type specific state
tz_micheline_state micheline; /// micheline parser state
tz_operation_state operation; /// operation parser state
tz_parser_result errno; /// current parser result
} tz_parser_state;

/**
Expand Down
12 changes: 6 additions & 6 deletions app/src/ui_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ typedef struct {
#ifdef HAVE_BAGL
tz_ui_icon_t icon; /// Icon to display on the screen.
tz_ui_layout_type_t
layout_type; /// Layout type for the screen. CAN BP, BNP, NP, PB or
/// HOME_X where X can be one of the BP, BNP, PB.
char *title; /// Title to display on the screen.
char *body[TZ_UI_STREAM_CONTENTS_LINES]; /// Body to display on the
/// screen (Below title).
short body_len; /// number of non-empty lines in the body.
layout_type; /// Layout type for the screen. CAN BP, BNP, NP, PB or
/// HOME_X where X can be one of the BP, BNP, PB.
uint8_t body_len; /// number of non-empty lines in the body.
char *title; /// Title to display on the screen.
char *body[TZ_UI_STREAM_CONTENTS_LINES]; /// Body to display on the
/// screen (Below title).
#else
nbgl_layoutTagValue_t
pairs[NB_MAX_DISPLAYED_PAIRS_IN_REVIEW]; /// Title-value pairs to be
Expand Down
2 changes: 1 addition & 1 deletion app/src/ui_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/

#ifdef TARGET_NANOS
#define BUFF_LEN 120 /// Ring buffer length of nanos
#define BUFF_LEN 114 /// Ring buffer length of nanos
#elif defined(HAVE_BAGL)
#define BUFF_LEN 256 /// Ring buffer length for nanos2/nanox
#else
Expand Down

0 comments on commit a907073

Please sign in to comment.