Fix some "out of memory" comments and few cosmetics

This commit is contained in:
Felipe Oliveira Carvalho
2014-05-31 00:49:17 -03:00
parent f4002c97dc
commit 3cb3c20b74
5 changed files with 12 additions and 15 deletions

View File

@@ -9,6 +9,7 @@
#include "nvim/vim.h"
#include "nvim/charset.h"
#include "nvim/farsi.h"
#include "nvim/func_attr.h"
#include "nvim/main.h"
#include "nvim/mbyte.h"
#include "nvim/memline.h"
@@ -321,12 +322,12 @@ void trans_characters(char_u *buf, int bufsize)
}
/// Translate a string into allocated memory, replacing special chars with
/// printable chars. Returns NULL when out of memory.
/// printable chars.
///
/// @param s
///
/// @return translated string
char_u *transstr(char_u *s)
char_u *transstr(char_u *s) FUNC_ATTR_NONNULL_RET
{
char_u *res;
char_u *p;

View File

@@ -7975,7 +7975,7 @@ static int ins_tab(void)
/*
* Handle CR or NL in insert mode.
* Return TRUE when out of memory or can't undo.
* Return TRUE when it can't undo.
*/
static int ins_eol(int c)
{

View File

@@ -5150,7 +5150,7 @@ static void list_extend(list_T *l1, list_T *l2, listitem_T *bef)
/*
* Concatenate lists "l1" and "l2" into a new list, stored in "tv".
* Return FAIL when out of memory.
* Return FAIL on failure to copy.
*/
static int list_concat(list_T *l1, list_T *l2, typval_T *tv)
{
@@ -5175,7 +5175,7 @@ static int list_concat(list_T *l1, list_T *l2, typval_T *tv)
* Make a copy of list "orig". Shallow if "deep" is FALSE.
* The refcount of the new list is set to 1.
* See item_copy() for "copyID".
* Returns NULL when out of memory.
* Returns NULL if orig is NULL or some failure happens.
*/
static list_T *list_copy(list_T *orig, int deep, int copyID)
{
@@ -5721,7 +5721,7 @@ void dictitem_free(dictitem_T *item)
* Make a copy of dict "d". Shallow if "deep" is FALSE.
* The refcount of the new dict is set to 1.
* See item_copy() for "copyID".
* Returns NULL when out of memory.
* Returns NULL if orig is NULL or some other failure.
*/
static dict_T *dict_copy(dict_T *orig, int deep, int copyID)
{
@@ -5865,7 +5865,7 @@ dictitem_T *dict_find(dict_T *d, char_u *key, int len)
/*
* Get a string item from a dictionary.
* When "save" is TRUE allocate memory for it.
* Returns NULL if the entry doesn't exist or out of memory.
* Returns NULL if the entry doesn't exist or some other failure.
*/
char_u *get_dict_string(dict_T *d, char_u *key, int save)
{
@@ -5883,13 +5883,11 @@ char_u *get_dict_string(dict_T *d, char_u *key, int save)
/*
* Get a number item from a dictionary.
* Returns 0 if the entry doesn't exist or out of memory.
* Returns 0 if the entry doesn't exist.
*/
long get_dict_number(dict_T *d, char_u *key)
{
dictitem_T *di;
di = dict_find(d, key, -1);
dictitem_T *di = dict_find(d, key, -1);
if (di == NULL)
return 0;
return get_tv_number(&di->di_tv);
@@ -17436,7 +17434,7 @@ static void func_do_profile(ufunc_T *fp)
fp->uf_tml_idx = -1;
if (fp->uf_tml_count == NULL || fp->uf_tml_total == NULL
|| fp->uf_tml_self == NULL)
return; /* out of memory */
return;
fp->uf_profiling = TRUE;
}

View File

@@ -1853,7 +1853,7 @@ int viminfo_readline(vir_T *virp)
*
* Check for a long line as written by viminfo_writestring().
*
* Return the string in allocated memory (NULL when out of memory).
* Return the string in allocated memory (or NULL to indicate failure).
*/
char_u *
viminfo_readstring (

View File

@@ -3528,8 +3528,6 @@ static char_u * iconv_string(vimconv_T *vcp, char_u *str, int slen, int *unconvl
memmove(p, result, done);
free(result);
result = p;
if (result == NULL) /* out of memory */
break;
}
to = (char *)result + done;