Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Dec 15, 2024
1 parent 07b7d48 commit b2178c4
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions vlib/v/gen/c/json.v
Original file line number Diff line number Diff line change
Expand Up @@ -842,11 +842,7 @@ fn (mut g Gen) gen_struct_enc_dec(utyp ast.Type, type_info ast.TypeInfo, styp st
dec)
}
if field.typ.has_flag(.option) {
if field_sym.kind == .array_fixed {
dec.writeln('\t\tvmemcpy(&${prefix}${op}${c_name(field.name)}, (${field_type}*)${tmp}.data, sizeof(${field_type}));')
} else {
dec.writeln('\t\tvmemcpy(&${prefix}${op}${c_name(field.name)}, (${field_type}*)${tmp}.data, sizeof(${field_type}));')
}
dec.writeln('\t\tvmemcpy(&${prefix}${op}${c_name(field.name)}, (${field_type}*)${tmp}.data, sizeof(${field_type}));')
} else {
if field_sym.kind == .array_fixed {
dec.writeln('\t\tvmemcpy(${prefix}${op}${c_name(field.name)},*(${field_type}*)${tmp}.data,sizeof(${field_type}));')
Expand Down Expand Up @@ -1029,7 +1025,7 @@ fn (mut g Gen) decode_array(utyp ast.Type, value_type ast.Type, fixed_array_size
if fixed_array_size > -1 {
fixed_array_idx += 'int fixed_array_idx = 0;'
array_element_assign += '((${styp}*)res.data)[fixed_array_idx] = val;'
fixed_array_idx_increment += 'fixed_array_idx++;'
fixed_array_idx_increment += 'fixed_array_idx++; res.state = 0;'
} else {
array_element_assign += 'array_push${noscan}((array*)&res.data, &val);'
res_str += '_option_ok(&(${g.base_type(utyp)}[]) { __new_array${noscan}(0, 0, sizeof(${styp})) }, (${option_name}*)&res, sizeof(${g.base_type(utyp)}));'
Expand Down

0 comments on commit b2178c4

Please sign in to comment.