Skip to content

Commit 06335c3

Browse files
committed
reduce memory usage
1 parent f9718b3 commit 06335c3

3 files changed

Lines changed: 34 additions & 33 deletions

File tree

app/src/metadata_reader.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ parser_error_t metadata_read(parser_context_t *ctx, parser_tx_t *txObj) {
523523
for (uint32_t i = 0; i < txObj->schema.types.qty; i++) {
524524
// read type
525525
CHECK_ERROR(read_u8(ctx, (uint8_t *)&txObj->schema.types.schemes[i].type));
526+
print_u8("type:", txObj->schema.types.schemes[i].type);
526527
switch (txObj->schema.types.schemes[i].type) {
527528
case LINKING_SCHEME_ENUM:
528529
print_string("READING ENUM");
@@ -589,8 +590,8 @@ parser_error_t metadata_read(parser_context_t *ctx, parser_tx_t *txObj) {
589590
break;
590591
case LINKING_SCHEME_MAP:
591592
print_string("READING MAP");
592-
CHECK_ERROR(read_link(ctx, &txObj->schema.types.schemes[i].map_type.key));
593-
CHECK_ERROR(read_link(ctx, &txObj->schema.types.schemes[i].map_type.value));
593+
CHECK_ERROR(read_link(ctx, &txObj->schema.types.schemes[i].map_type->key));
594+
CHECK_ERROR(read_link(ctx, &txObj->schema.types.schemes[i].map_type->value));
594595
print_string("READING MAP DONE\n");
595596
break;
596597
default:

app/src/txdefs/metadata_txdef.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,15 @@ typedef struct {
9191
} fixed_point_display_from_sibling_field_t;
9292

9393
typedef struct {
94-
fixed_point_display_type_t type;
94+
uint8_t type;
9595
union {
9696
uint8_t decimals;
9797
fixed_point_display_from_sibling_field_t from_sibling_field;
9898
};
9999
} fixed_point_display_t;
100100

101101
typedef struct {
102-
integer_display_type_t type;
102+
uint8_t type;
103103
union {
104104
fixed_point_display_t fixed_point;
105105
};
@@ -118,15 +118,15 @@ typedef struct {
118118
} byte_display_bech32m_t;
119119

120120
typedef struct {
121-
byte_display_type_t type;
121+
uint8_t type;
122122
union {
123123
byte_display_bech32_t bech32;
124124
byte_display_bech32m_t bech32m;
125125
};
126126
} byte_display_t;
127127

128128
typedef struct {
129-
integer_type_t type;
129+
uint8_t type;
130130
integer_display_t display;
131131
} primitive_integer_t;
132132

@@ -144,7 +144,7 @@ typedef struct {
144144
} primitive_skip_t;
145145

146146
typedef struct {
147-
primitive_type_t type;
147+
uint8_t type;
148148
union {
149149
primitive_integer_t integer;
150150
primitive_byte_array_t byte_array;
@@ -231,19 +231,19 @@ typedef struct {
231231
} schema_map_t;
232232

233233
typedef struct {
234-
linking_scheme_type_t type;
234+
uint8_t type;
235235
union {
236-
schema_enum_t enum_type;
237-
schema_struct_t struct_type;
238-
schema_tuple_t tuple_type;
239-
link_t option_type;
240-
primitive_integer_t integer_type;
241-
primitive_byte_array_t byte_array_type;
242-
uint64_t skip_type;
243-
byte_display_t byte_vec_type;
244-
schema_array_t array_type;
245-
link_t vec_type;
246-
schema_map_t map_type;
236+
const schema_enum_t* enum_type;
237+
const schema_struct_t* struct_type;
238+
const schema_tuple_t* tuple_type;
239+
const link_t* option_type;
240+
const primitive_integer_t* integer_type;
241+
const primitive_byte_array_t* byte_array_type;
242+
const uint64_t skip_type;
243+
const byte_display_t* byte_vec_type;
244+
const schema_array_t* array_type;
245+
const link_t* vec_type;
246+
const schema_map_t* map_type;
247247
};
248248
} linking_scheme_t;
249249

0 commit comments

Comments
 (0)