mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 22:18:33 +00:00
Merge #708 'Remove NULL/non-NULL tests after vim_str(n)save'
- replace alloc with xmalloc
This commit is contained in:
@@ -594,10 +594,7 @@ int u_savecommon(linenr_T top, linenr_T bot, linenr_T newbot, int reload)
|
||||
u_freeentry(uep, i);
|
||||
return FAIL;
|
||||
}
|
||||
if ((uep->ue_array[i] = u_save_line(lnum++)) == NULL) {
|
||||
u_freeentry(uep, i);
|
||||
goto nomem;
|
||||
}
|
||||
uep->ue_array[i] = u_save_line(lnum++);
|
||||
}
|
||||
} else
|
||||
uep->ue_array = NULL;
|
||||
@@ -610,16 +607,6 @@ int u_savecommon(linenr_T top, linenr_T bot, linenr_T newbot, int reload)
|
||||
u_check(FALSE);
|
||||
#endif
|
||||
return OK;
|
||||
|
||||
nomem:
|
||||
msg_silent = 0; /* must display the prompt */
|
||||
if (ask_yesno((char_u *)_("No undo possible; continue anyway"), TRUE)
|
||||
== 'y') {
|
||||
undo_off = TRUE; /* will be reset when character typed */
|
||||
return OK;
|
||||
}
|
||||
do_outofmem_msg((long_u)0);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
|
||||
@@ -695,8 +682,6 @@ char_u *u_get_undo_file_name(char_u *buf_ffname, int reading)
|
||||
/* Use same directory as the ffname,
|
||||
* "dir/name" -> "dir/.name.un~" */
|
||||
undo_file_name = vim_strnsave(ffname, (int)(STRLEN(ffname) + 5));
|
||||
if (undo_file_name == NULL)
|
||||
break;
|
||||
p = path_tail(undo_file_name);
|
||||
memmove(p + 1, p, STRLEN(p) + 1);
|
||||
*p = '.';
|
||||
@@ -706,8 +691,6 @@ char_u *u_get_undo_file_name(char_u *buf_ffname, int reading)
|
||||
if (os_isdir(dir_name)) {
|
||||
if (munged_name == NULL) {
|
||||
munged_name = vim_strsave(ffname);
|
||||
if (munged_name == NULL)
|
||||
return NULL;
|
||||
for (p = munged_name; *p != NUL; mb_ptr_adv(p))
|
||||
if (vim_ispathsep(*p))
|
||||
*p = '%';
|
||||
@@ -2034,8 +2017,7 @@ static void u_undoredo(int undo)
|
||||
/* delete backwards, it goes faster in most cases */
|
||||
for (lnum = bot - 1, i = oldsize; --i >= 0; --lnum) {
|
||||
/* what can we do when we run out of memory? */
|
||||
if ((newarray[i] = u_save_line(lnum)) == NULL)
|
||||
do_outofmem_msg((long_u)0);
|
||||
newarray[i] = u_save_line(lnum);
|
||||
/* remember we deleted the last line in the buffer, and a
|
||||
* dummy empty line will be inserted */
|
||||
if (curbuf->b_ml.ml_line_count == 1)
|
||||
@@ -2666,8 +2648,7 @@ void u_saveline(linenr_T lnum)
|
||||
curbuf->b_u_line_colnr = curwin->w_cursor.col;
|
||||
else
|
||||
curbuf->b_u_line_colnr = 0;
|
||||
if ((curbuf->b_u_line_ptr = u_save_line(lnum)) == NULL)
|
||||
do_outofmem_msg((long_u)0);
|
||||
curbuf->b_u_line_ptr = u_save_line(lnum);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2708,10 +2689,6 @@ void u_undoline(void)
|
||||
curbuf->b_u_line_lnum + 1, (linenr_T)0, FALSE) == FAIL)
|
||||
return;
|
||||
oldp = u_save_line(curbuf->b_u_line_lnum);
|
||||
if (oldp == NULL) {
|
||||
do_outofmem_msg((long_u)0);
|
||||
return;
|
||||
}
|
||||
ml_replace(curbuf->b_u_line_lnum, curbuf->b_u_line_ptr, TRUE);
|
||||
changed_bytes(curbuf->b_u_line_lnum, 0);
|
||||
free(curbuf->b_u_line_ptr);
|
||||
@@ -2737,7 +2714,6 @@ void u_blockfree(buf_T *buf)
|
||||
|
||||
/*
|
||||
* u_save_line(): allocate memory and copy line 'lnum' into it.
|
||||
* Returns NULL when out of memory.
|
||||
*/
|
||||
static char_u *u_save_line(linenr_T lnum)
|
||||
{
|
||||
|
Reference in New Issue
Block a user