src/json.c

changeset 1611
de21dd0d1426
parent 1608
46d8a8305948
equal deleted inserted replaced
1610:ce0b0bf7d29c 1611:de21dd0d1426
504 // add the new value to the stack, if it is an array or object 504 // add the new value to the stack, if it is an array or object
505 if (type == CX_JSON_ARRAY || type == CX_JSON_OBJECT) { 505 if (type == CX_JSON_ARRAY || type == CX_JSON_OBJECT) {
506 if (json->vbuf.size >= json->vbuf.capacity) { 506 if (json->vbuf.size >= json->vbuf.capacity) {
507 int alloc_error; 507 int alloc_error;
508 if (json->vbuf.data == json->vbuf_internal) { 508 if (json->vbuf.data == json->vbuf_internal) {
509 alloc_error = cx_array_move_to_new(json->vbuf, json->vbuf.size+1); 509 alloc_error = cx_array_copy_to_new(json->vbuf, json->vbuf.size+1);
510 } else { 510 } else {
511 alloc_error = cx_array_reserve(json->vbuf, json->vbuf.size+1); 511 alloc_error = cx_array_reserve(json->vbuf, json->vbuf.size+1);
512 } 512 }
513 if (alloc_error) { 513 if (alloc_error) {
514 goto create_json_value_exit_error; // LCOV_EXCL_LINE 514 goto create_json_value_exit_error; // LCOV_EXCL_LINE
618 // guarantee that at least two more states fit into the array 618 // guarantee that at least two more states fit into the array
619 const size_t required_states_depth = json->states.size + 2; 619 const size_t required_states_depth = json->states.size + 2;
620 if (required_states_depth >= json->states.capacity) { 620 if (required_states_depth >= json->states.capacity) {
621 int alloc_error; 621 int alloc_error;
622 if (json->states.data == json->states_internal) { 622 if (json->states.data == json->states_internal) {
623 alloc_error = cx_array_move_to_new(json->states, required_states_depth); 623 alloc_error = cx_array_copy_to_new(json->states, required_states_depth);
624 } else { 624 } else {
625 alloc_error = cx_array_reserve(json->states, required_states_depth); 625 alloc_error = cx_array_reserve(json->states, required_states_depth);
626 } 626 }
627 if (alloc_error) { 627 if (alloc_error) {
628 return CX_JSON_BUFFER_ALLOC_FAILED; // LCOV_EXCL_LINE 628 return CX_JSON_BUFFER_ALLOC_FAILED; // LCOV_EXCL_LINE

mercurial