mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
HAVE_AVAIL_MEM is always undefined. Remove tests and dead code
Defining HAVE_AVAIL_MEM doesn't even build. The code tries to call `mch_avail_mem` which is not defined.
This commit is contained in:
parent
83161200c4
commit
580ababcb5
36
src/misc2.c
36
src/misc2.c
@ -598,13 +598,6 @@ int leftcol_changed(void)
|
||||
* Various routines dealing with allocation and deallocation of memory.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Some memory is reserved for error messages and for being able to
|
||||
* call mf_release_all(), which needs some memory for mf_trans_add().
|
||||
*/
|
||||
# define KEEP_ROOM (2 * 8192L)
|
||||
#define KEEP_ROOM_KB (KEEP_ROOM / 1024L)
|
||||
|
||||
/*
|
||||
* Note: if unsigned is 16 bits we can only allocate up to 64K with alloc().
|
||||
* Use lalloc for larger blocks.
|
||||
@ -665,9 +658,6 @@ char_u *lalloc(long_u size, int message)
|
||||
char_u *p; /* pointer to new storage space */
|
||||
static int releasing = FALSE; /* don't do mf_release_all() recursive */
|
||||
int try_again;
|
||||
#if defined(HAVE_AVAIL_MEM) && !defined(SMALL_MEM)
|
||||
static long_u allocated = 0; /* allocated since last avail check */
|
||||
#endif
|
||||
|
||||
/* Safety check for allocating zero bytes */
|
||||
if (size == 0) {
|
||||
@ -682,33 +672,9 @@ char_u *lalloc(long_u size, int message)
|
||||
* if some blocks are released call malloc again.
|
||||
*/
|
||||
for (;; ) {
|
||||
/*
|
||||
* Handle three kind of systems:
|
||||
* 1. No check for available memory: Just return.
|
||||
* 2. Slow check for available memory: call mch_avail_mem() after
|
||||
* allocating KEEP_ROOM amount of memory.
|
||||
* 3. Strict check for available memory: call mch_avail_mem()
|
||||
*/
|
||||
if ((p = (char_u *)malloc((size_t)size)) != NULL) {
|
||||
#ifndef HAVE_AVAIL_MEM
|
||||
/* 1. No check for available memory: Just return. */
|
||||
/* No check for available memory: Just return. */
|
||||
goto theend;
|
||||
#else
|
||||
# ifndef SMALL_MEM
|
||||
/* 2. Slow check for available memory: call mch_avail_mem() after
|
||||
* allocating (KEEP_ROOM / 2) amount of memory. */
|
||||
allocated += size;
|
||||
if (allocated < KEEP_ROOM / 2)
|
||||
goto theend;
|
||||
allocated = 0;
|
||||
# endif
|
||||
/* 3. check for available memory: call mch_avail_mem() */
|
||||
if (mch_avail_mem(TRUE) < KEEP_ROOM_KB && !releasing) {
|
||||
free((char *)p); /* System is low... no go! */
|
||||
p = NULL;
|
||||
} else
|
||||
goto theend;
|
||||
#endif
|
||||
}
|
||||
/*
|
||||
* Remember that mf_release_all() is being called to avoid an endless
|
||||
|
13
src/option.c
13
src/option.c
@ -2024,25 +2024,20 @@ void set_init_1(void)
|
||||
*/
|
||||
opt_idx = findoption((char_u *)"maxmemtot");
|
||||
if (opt_idx >= 0) {
|
||||
#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
|
||||
#ifndef HAVE_TOTAL_MEM
|
||||
if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
|
||||
#endif
|
||||
{
|
||||
#ifdef HAVE_AVAIL_MEM
|
||||
/* Use amount of memory available at this moment. */
|
||||
n = (mch_avail_mem(FALSE) >> 1);
|
||||
#else
|
||||
# ifdef HAVE_TOTAL_MEM
|
||||
#ifdef HAVE_TOTAL_MEM
|
||||
/* Use amount of memory available to Vim. */
|
||||
n = (mch_total_mem(FALSE) >> 1);
|
||||
# else
|
||||
#else
|
||||
n = (0x7fffffff >> 11);
|
||||
# endif
|
||||
#endif
|
||||
options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
|
||||
opt_idx = findoption((char_u *)"maxmem");
|
||||
if (opt_idx >= 0) {
|
||||
#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
|
||||
#ifndef HAVE_TOTAL_MEM
|
||||
if ((long)options[opt_idx].def_val[VI_DEFAULT] > (long)n
|
||||
|| (long)options[opt_idx].def_val[VI_DEFAULT] == 0L)
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user