diff options
author | Felipe Oliveira Carvalho <felipekde@gmail.com> | 2014-05-08 21:34:46 -0300 |
---|---|---|
committer | Felipe Oliveira Carvalho <felipekde@gmail.com> | 2014-05-19 14:50:23 -0300 |
commit | a80d7e86c1f088c5b68d8e8929cc72a0d9680f76 (patch) | |
tree | cc9cc71ee35fe966779cf6764bd5faabd1186df3 /src/nvim/ops.c | |
parent | b63d2626ed9e3e38a485b9990a8e65ba59d6906a (diff) | |
download | rneovim-a80d7e86c1f088c5b68d8e8929cc72a0d9680f76.tar.gz rneovim-a80d7e86c1f088c5b68d8e8929cc72a0d9680f76.tar.bz2 rneovim-a80d7e86c1f088c5b68d8e8929cc72a0d9680f76.zip |
Remove NULL/non-NULL tests after calls to vim_str(n)save()
Diffstat (limited to 'src/nvim/ops.c')
-rw-r--r-- | src/nvim/ops.c | 64 |
1 files changed, 23 insertions, 41 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index dff9822dd0..dd5314e571 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -689,8 +689,6 @@ char_u *get_expr_line(void) /* Make a copy of the expression, because evaluating it may cause it to be * changed. */ expr_copy = vim_strsave(expr_line); - if (expr_copy == NULL) - return NULL; /* When we are invoked recursively limit the evaluation to 10 levels. * Then return the string as-is. */ @@ -2154,17 +2152,15 @@ void op_insert(oparg_T *oap, long count1) if (pre_textlen >= 0 && (ins_len = (long)STRLEN(firstline) - pre_textlen) > 0) { ins_text = vim_strnsave(firstline, (int)ins_len); - if (ins_text != NULL) { - /* block handled here */ - if (u_save(oap->start.lnum, - (linenr_T)(oap->end.lnum + 1)) == OK) - block_insert(oap, ins_text, (oap->op_type == OP_INSERT), - &bd); - - curwin->w_cursor.col = oap->start.col; - check_cursor(); - free(ins_text); - } + /* block handled here */ + if (u_save(oap->start.lnum, + (linenr_T)(oap->end.lnum + 1)) == OK) + block_insert(oap, ins_text, (oap->op_type == OP_INSERT), + &bd); + + curwin->w_cursor.col = oap->start.col; + check_cursor(); + free(ins_text); } } } @@ -2414,9 +2410,7 @@ int op_yank(oparg_T *oap, int deleting, int mess) break; case MLINE: - if ((y_current->y_array[y_idx] = - vim_strsave(ml_get(lnum))) == NULL) - goto fail; + y_current->y_array[y_idx] = vim_strsave(ml_get(lnum)); break; case MCHAR: @@ -2547,13 +2541,7 @@ int op_yank(oparg_T *oap, int deleting, int mess) curbuf->b_op_end.col = MAXCOL; } - return OK; - -fail: /* free the allocated lines */ - free_yank(y_idx + 1); - y_current = curr; - return FAIL; } static void yank_copy_line(struct block_def *bd, long y_idx) @@ -2699,14 +2687,10 @@ do_put ( if (u_save_cursor() == FAIL) goto end; ptr = vim_strsave(ml_get_cursor()); - if (ptr == NULL) - goto end; ml_append(curwin->w_cursor.lnum, ptr, (colnr_T)0, FALSE); free(ptr); ptr = vim_strnsave(ml_get_curline(), curwin->w_cursor.col); - if (ptr == NULL) - goto end; ml_replace(curwin->w_cursor.lnum, ptr, FALSE); ++nr_lines; dir = FORWARD; @@ -3628,20 +3612,19 @@ static int same_leader(linenr_T lnum, int leader1_len, char_u *leader1_flags, in * The first line has to be saved, only one line can be locked at a time. */ line1 = vim_strsave(ml_get(lnum)); - if (line1 != NULL) { - for (idx1 = 0; vim_iswhite(line1[idx1]); ++idx1) - ; - line2 = ml_get(lnum + 1); - for (idx2 = 0; idx2 < leader2_len; ++idx2) { - if (!vim_iswhite(line2[idx2])) { - if (line1[idx1++] != line2[idx2]) - break; - } else - while (vim_iswhite(line1[idx1])) - ++idx1; - } - free(line1); + for (idx1 = 0; vim_iswhite(line1[idx1]); ++idx1) + ; + line2 = ml_get(lnum + 1); + for (idx2 = 0; idx2 < leader2_len; ++idx2) { + if (!vim_iswhite(line2[idx2])) { + if (line1[idx1++] != line2[idx2]) + break; + } else + while (vim_iswhite(line1[idx1])) + ++idx1; } + free(line1); + return idx2 == leader2_len && idx1 == leader1_len; } @@ -4773,8 +4756,7 @@ void write_reg_contents_ex(int name, char_u *str, int maxlen, int must_append, i char_u *p, *s; p = vim_strnsave(str, (int)len); - if (p == NULL) - return; + if (must_append) { s = concat_str(get_expr_line_src(), p); free(p); |