Commit 9ac0d9e0 authored by Jim Blandy's avatar Jim Blandy

Put interrupt input blocking in a separate file from xterm.h.

	This isn't specific to X, and it allows us to avoid #including
	xterm.h in files that don't really have anything to do with X.
	* blockinput.h: New file.
	* xterm.h (BLOCK_INPUT, UNBLOCK_INPUT, TOTALLY_UNBLOCK_INPUT,
	UNBLOCK_INPUT_RESIGNAL): These are now in blockinput.h.
	(x_input_blocked, x_pending_input): Deleted; there are analogs
	in blockinput.h called interrupt_input_blocked and
	interrupt_input_pending.
	* keyboard.c (interrupt_input_blocked, interrupt_input_pending):
	New variables, used by the macros in blockinput.h.
	* xterm.c: #include blockinput.h.
	(x_input_blocked, x_pending_input): Deleted.
	(XTread_socket): Test and set interrupt_input_blocked and
	interrupt_input_pending instead of the old variables.
	* alloc.c, xfaces.c, xfns.c, xmenu.c, xselect.c, keymap.c:
	#include blockinput.h.
	* eval.c: #include blockinput.h instead of xterm.h.
	* keyboard.c: #include blockinput.h.
	(input_poll_signal): Just test
	interrupt_input_blocked, instead of testing HAVE_X_WINDOWS and
	x_input_blocked.

	Block the processing of interrupt input while we're manipulating the
	malloc heap.
	* alloc.c: (xfree): New function, to make it easy to free things
	safely.
	(xmalloc, xrealloc): Block X input while doing the deed.
	(VALIDATE_LISP_STORAGE, gc_sweep, compact_strings): Use xfree
	instead of free.
	(uninterrupt_malloc): New function, to install input-blocking
	hooks into the GNU malloc routines.
	* emacs.c [not SYSTEM_MALLOC] (main): Call uninterrupt_malloc
	on startup.
	* alloc.c: (make_interval, make_float, Fcons, Fmake_vector,
	Fmake_symbol, Fmake_marker, make_uninit_string, Fgarbage_collect):
	Use xmalloc instead of malloc; don't bother to check if out of
	memory here.
	(Fgarbage_collect): Call xrealloc instead of realloc.
	* buffer.c: Use xmalloc and xfree instead of malloc and free;
	don't bother to check if out of memory here.
	(Fget_buffer_create): Put BLOCK_INPUT/UNBLOCK_INPUT pair around
	calls to ralloc routines.
	* insdel.c: Same.
	* lisp.h (xfree): New extern declaration.
	* xfaces.c (xfree): Don't #define this to be free; use the
	definition in alloc.c.
	* dispnew.c, doc.c, doprnt.c, fileio.c, lread.c, term.c, xfns.c,
	xmenu.c, xterm.c: Use xfree instead of free.
	* hftctl.c: Use xfree and xmalloc instead of free and malloc.
	* keymap.c (current_minor_maps): BLOCK_INPUT while calling realloc
	and malloc.
	* search.c: Since the regexp routines can malloc, BLOCK_INPUT
	while runing them.  #include blockinput.h.
	* sysdep.c: #include blockinput.h.  Call xfree and xmalloc instead
	of free and malloc.  BLOCK_INPUT around routines which we know
	will call malloc.

	ymakefile (keyboard.o, keymap.o, search.o, sysdep.o, xfaces.o,
	xfns.o, xmenu.o, xterm.o, xselect.o, alloc.o, eval.o): Note that
	these depend on blockinput.h.
parent 357f32fc
...@@ -26,6 +26,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ ...@@ -26,6 +26,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "buffer.h" #include "buffer.h"
#include "window.h" #include "window.h"
#include "frame.h" #include "frame.h"
#include "blockinput.h"
#endif #endif
#include "syssignal.h" #include "syssignal.h"
...@@ -43,7 +44,7 @@ do \ ...@@ -43,7 +44,7 @@ do \
XSET (val, Lisp_Cons, (char *) address + size); \ XSET (val, Lisp_Cons, (char *) address + size); \
if ((char *) XCONS (val) != (char *) address + size) \ if ((char *) XCONS (val) != (char *) address + size) \
{ \ { \
free (address); \ xfree (address); \
memory_full (); \ memory_full (); \
} \ } \
} while (0) } while (0)
...@@ -149,7 +150,7 @@ memory_full () ...@@ -149,7 +150,7 @@ memory_full ()
error ("Memory exhausted"); error ("Memory exhausted");
} }
/* like malloc and realloc but check for no memory left */ /* like malloc routines but check for no memory and block interrupt input. */
long * long *
xmalloc (size) xmalloc (size)
...@@ -157,7 +158,9 @@ xmalloc (size) ...@@ -157,7 +158,9 @@ xmalloc (size)
{ {
register long *val; register long *val;
BLOCK_INPUT;
val = (long *) malloc (size); val = (long *) malloc (size);
UNBLOCK_INPUT;
if (!val && size) memory_full (); if (!val && size) memory_full ();
return val; return val;
...@@ -170,16 +173,99 @@ xrealloc (block, size) ...@@ -170,16 +173,99 @@ xrealloc (block, size)
{ {
register long *val; register long *val;
BLOCK_INPUT;
/* We must call malloc explicitly when BLOCK is 0, since some /* We must call malloc explicitly when BLOCK is 0, since some
reallocs don't do this. */ reallocs don't do this. */
if (! block) if (! block)
val = (long *) malloc (size); val = (long *) malloc (size);
else else
val = (long *) realloc (block, size); val = (long *) realloc (block, size);
UNBLOCK_INPUT;
if (!val && size) memory_full (); if (!val && size) memory_full ();
return val; return val;
} }
void
xfree (block)
long *block;
{
BLOCK_INPUT;
free (block);
UNBLOCK_INPUT;
}
/* Arranging to disable input signals while we're in malloc.
This only works with GNU malloc. To help out systems which can't
use GNU malloc, all the calls to malloc, realloc, and free
elsewhere in the code should be inside a BLOCK_INPUT/UNBLOCK_INPUT
pairs; unfortunately, we have no idea what C library functions
might call malloc, so we can't really protect them unless you're
using GNU malloc. Fortunately, most of the major operating can use
GNU malloc. */
#ifndef SYSTEM_MALLOC
static void (*__malloc_hook) (), (*old_malloc_hook) ();
static void (*__realloc_hook) (), (*old_realloc_hook) ();
static void (*__free_hook) (), (*old_free_hook) ();
static void
emacs_blocked_free (ptr)
void *ptr;
{
BLOCK_INPUT;
__free_hook = old_free_hook;
free (ptr);
__free_hook = &emacs_blocked_free;
UNBLOCK_INPUT;
}
static void *
emacs_blocked_malloc (size)
unsigned size;
{
void *value;
BLOCK_INPUT;
__malloc_hook = old_malloc_hook;
value = malloc (size);
__malloc_hook = &emacs_blocked_malloc;
UNBLOCK_INPUT;
return value;
}
static void *
emacs_blocked_realloc (ptr, size)
void *ptr;
unsigned size;
{
void *value;
BLOCK_INPUT;
__realloc_hook = old_realloc_hook;
value = realloc (ptr, size);
__realloc_hook = &emacs_blocked_realloc;
UNBLOCK_INPUT;
return value;
}
void
uninterrupt_malloc ()
{
old_free_hook = __free_hook;
__free_hook = &emacs_blocked_free;
old_malloc_hook = __malloc_hook;
__malloc_hook = &emacs_blocked_malloc;
old_realloc_hook = __realloc_hook;
__realloc_hook = &emacs_blocked_realloc;
}
#endif
/* Interval allocation. */ /* Interval allocation. */
...@@ -226,10 +312,7 @@ make_interval () ...@@ -226,10 +312,7 @@ make_interval ()
if (interval_block_index == INTERVAL_BLOCK_SIZE) if (interval_block_index == INTERVAL_BLOCK_SIZE)
{ {
register struct interval_block *newi register struct interval_block *newi
= (struct interval_block *) malloc (sizeof (struct interval_block)); = (struct interval_block *) xmalloc (sizeof (struct interval_block));
if (!newi)
memory_full ();
VALIDATE_LISP_STORAGE (newi, sizeof *newi); VALIDATE_LISP_STORAGE (newi, sizeof *newi);
newi->next = interval_block; newi->next = interval_block;
...@@ -352,8 +435,7 @@ make_float (float_value) ...@@ -352,8 +435,7 @@ make_float (float_value)
{ {
if (float_block_index == FLOAT_BLOCK_SIZE) if (float_block_index == FLOAT_BLOCK_SIZE)
{ {
register struct float_block *new = (struct float_block *) malloc (sizeof (struct float_block)); register struct float_block *new = (struct float_block *) xmalloc (sizeof (struct float_block));
if (!new) memory_full ();
VALIDATE_LISP_STORAGE (new, sizeof *new); VALIDATE_LISP_STORAGE (new, sizeof *new);
new->next = float_block; new->next = float_block;
float_block = new; float_block = new;
...@@ -427,8 +509,7 @@ DEFUN ("cons", Fcons, Scons, 2, 2, 0, ...@@ -427,8 +509,7 @@ DEFUN ("cons", Fcons, Scons, 2, 2, 0,
{ {
if (cons_block_index == CONS_BLOCK_SIZE) if (cons_block_index == CONS_BLOCK_SIZE)
{ {
register struct cons_block *new = (struct cons_block *) malloc (sizeof (struct cons_block)); register struct cons_block *new = (struct cons_block *) xmalloc (sizeof (struct cons_block));
if (!new) memory_full ();
VALIDATE_LISP_STORAGE (new, sizeof *new); VALIDATE_LISP_STORAGE (new, sizeof *new);
new->next = cons_block; new->next = cons_block;
cons_block = new; cons_block = new;
...@@ -498,9 +579,7 @@ See also the function `vector'.") ...@@ -498,9 +579,7 @@ See also the function `vector'.")
length = wrong_type_argument (Qnatnump, length); length = wrong_type_argument (Qnatnump, length);
sizei = XINT (length); sizei = XINT (length);
p = (struct Lisp_Vector *) malloc (sizeof (struct Lisp_Vector) + (sizei - 1) * sizeof (Lisp_Object)); p = (struct Lisp_Vector *) xmalloc (sizeof (struct Lisp_Vector) + (sizei - 1) * sizeof (Lisp_Object));
if (p == 0)
memory_full ();
VALIDATE_LISP_STORAGE (p, 0); VALIDATE_LISP_STORAGE (p, 0);
XSET (vector, Lisp_Vector, p); XSET (vector, Lisp_Vector, p);
...@@ -617,8 +696,7 @@ Its value and function definition are void, and its property list is nil.") ...@@ -617,8 +696,7 @@ Its value and function definition are void, and its property list is nil.")
{ {
if (symbol_block_index == SYMBOL_BLOCK_SIZE) if (symbol_block_index == SYMBOL_BLOCK_SIZE)
{ {
struct symbol_block *new = (struct symbol_block *) malloc (sizeof (struct symbol_block)); struct symbol_block *new = (struct symbol_block *) xmalloc (sizeof (struct symbol_block));
if (!new) memory_full ();
VALIDATE_LISP_STORAGE (new, sizeof *new); VALIDATE_LISP_STORAGE (new, sizeof *new);
new->next = symbol_block; new->next = symbol_block;
symbol_block = new; symbol_block = new;
...@@ -680,8 +758,7 @@ DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0, ...@@ -680,8 +758,7 @@ DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0,
{ {
if (marker_block_index == MARKER_BLOCK_SIZE) if (marker_block_index == MARKER_BLOCK_SIZE)
{ {
struct marker_block *new = (struct marker_block *) malloc (sizeof (struct marker_block)); struct marker_block *new = (struct marker_block *) xmalloc (sizeof (struct marker_block));
if (!new) memory_full ();
VALIDATE_LISP_STORAGE (new, sizeof *new); VALIDATE_LISP_STORAGE (new, sizeof *new);
new->next = marker_block; new->next = marker_block;
marker_block = new; marker_block = new;
...@@ -830,9 +907,8 @@ make_uninit_string (length) ...@@ -830,9 +907,8 @@ make_uninit_string (length)
/* This string gets its own string block */ /* This string gets its own string block */
{ {
register struct string_block *new register struct string_block *new
= (struct string_block *) malloc (sizeof (struct string_block_head) + fullsize); = (struct string_block *) xmalloc (sizeof (struct string_block_head) + fullsize);
VALIDATE_LISP_STORAGE (new, 0); VALIDATE_LISP_STORAGE (new, 0);
if (!new) memory_full ();
consing_since_gc += sizeof (struct string_block_head) + fullsize; consing_since_gc += sizeof (struct string_block_head) + fullsize;
new->pos = fullsize; new->pos = fullsize;
new->next = large_string_blocks; new->next = large_string_blocks;
...@@ -844,8 +920,7 @@ make_uninit_string (length) ...@@ -844,8 +920,7 @@ make_uninit_string (length)
/* Make a new current string block and start it off with this string */ /* Make a new current string block and start it off with this string */
{ {
register struct string_block *new register struct string_block *new
= (struct string_block *) malloc (sizeof (struct string_block)); = (struct string_block *) xmalloc (sizeof (struct string_block));
if (!new) memory_full ();
VALIDATE_LISP_STORAGE (new, sizeof *new); VALIDATE_LISP_STORAGE (new, sizeof *new);
consing_since_gc += sizeof (struct string_block); consing_since_gc += sizeof (struct string_block);
current_string_block->next = new; current_string_block->next = new;
...@@ -1149,9 +1224,9 @@ Garbage collection happens automatically if you cons more than\n\ ...@@ -1149,9 +1224,9 @@ Garbage collection happens automatically if you cons more than\n\
if (i < MAX_SAVE_STACK) if (i < MAX_SAVE_STACK)
{ {
if (stack_copy == 0) if (stack_copy == 0)
stack_copy = (char *) malloc (stack_copy_size = i); stack_copy = (char *) xmalloc (stack_copy_size = i);
else if (stack_copy_size < i) else if (stack_copy_size < i)
stack_copy = (char *) realloc (stack_copy, (stack_copy_size = i)); stack_copy = (char *) xrealloc (stack_copy, (stack_copy_size = i));
if (stack_copy) if (stack_copy)
{ {
if ((int) (&stack_top_variable - stack_bottom) > 0) if ((int) (&stack_top_variable - stack_bottom) > 0)
...@@ -1804,7 +1879,7 @@ gc_sweep () ...@@ -1804,7 +1879,7 @@ gc_sweep ()
else else
all_buffers = buffer->next; all_buffers = buffer->next;
next = buffer->next; next = buffer->next;
free (buffer); xfree (buffer);
buffer = next; buffer = next;
} }
else else
...@@ -1845,7 +1920,7 @@ gc_sweep () ...@@ -1845,7 +1920,7 @@ gc_sweep ()
else else
all_vectors = vector->next; all_vectors = vector->next;
next = vector->next; next = vector->next;
free (vector); xfree (vector);
vector = next; vector = next;
} }
else else
...@@ -1868,7 +1943,7 @@ gc_sweep () ...@@ -1868,7 +1943,7 @@ gc_sweep ()
else else
large_string_blocks = sb->next; large_string_blocks = sb->next;
next = sb->next; next = sb->next;
free (sb); xfree (sb);
sb = next; sb = next;
} }
else else
...@@ -1983,7 +2058,7 @@ compact_strings () ...@@ -1983,7 +2058,7 @@ compact_strings ()
while (from_sb) while (from_sb)
{ {
to_sb = from_sb->next; to_sb = from_sb->next;
free (from_sb); xfree (from_sb);
from_sb = to_sb; from_sb = to_sb;
} }
...@@ -1998,7 +2073,7 @@ compact_strings () ...@@ -1998,7 +2073,7 @@ compact_strings ()
{ {
if (from_sb->next = to_sb->next) if (from_sb->next = to_sb->next)
from_sb->next->prev = from_sb; from_sb->next->prev = from_sb;
free (to_sb); xfree (to_sb);
} }
else else
from_sb = to_sb; from_sb = to_sb;
......
/* Interface to blocking complicated interrupt-driven input. /* blockinput.h - interface to blocking complicated interrupt-driven input.
Copyright (C) 1989, 1993 Free Software Foundation, Inc. Copyright (C) 1989, 1993 Free Software Foundation, Inc.
This file is part of GNU Emacs. This file is part of GNU Emacs.
......
...@@ -197,12 +197,12 @@ The value is never nil.") ...@@ -197,12 +197,12 @@ The value is never nil.")
if (!NILP (buf)) if (!NILP (buf))
return buf; return buf;
b = (struct buffer *) malloc (sizeof (struct buffer)); b = (struct buffer *) xmalloc (sizeof (struct buffer));
if (!b)
memory_full ();
BUF_GAP_SIZE (b) = 20; BUF_GAP_SIZE (b) = 20;
BLOCK_INPUT;
BUFFER_ALLOC (BUF_BEG_ADDR (b), BUF_GAP_SIZE (b)); BUFFER_ALLOC (BUF_BEG_ADDR (b), BUF_GAP_SIZE (b));
UNBLOCK_INPUT;
if (! BUF_BEG_ADDR (b)) if (! BUF_BEG_ADDR (b))
memory_full (); memory_full ();
...@@ -750,7 +750,9 @@ with `delete-process'.") ...@@ -750,7 +750,9 @@ with `delete-process'.")
/* Perhaps we should explicitly free the interval tree here... */ /* Perhaps we should explicitly free the interval tree here... */
b->name = Qnil; b->name = Qnil;
BLOCK_INPUT;
BUFFER_FREE (BUF_BEG_ADDR (b)); BUFFER_FREE (BUF_BEG_ADDR (b));
UNBLOCK_INPUT;
b->undo_list = Qnil; b->undo_list = Qnil;
return Qt; return Qt;
...@@ -1513,7 +1515,7 @@ DEFUN ("overlays-at", Foverlays_at, Soverlays_at, 1, 1, 0, ...@@ -1513,7 +1515,7 @@ DEFUN ("overlays-at", Foverlays_at, Soverlays_at, 1, 1, 0,
/* Make a list of them all. */ /* Make a list of them all. */
result = Flist (noverlays, overlay_vec); result = Flist (noverlays, overlay_vec);
free (overlay_vec); xfree (overlay_vec);
return result; return result;
} }
...@@ -1553,7 +1555,7 @@ DEFUN ("next-overlay-change", Fnext_overlay_change, Snext_overlay_change, ...@@ -1553,7 +1555,7 @@ DEFUN ("next-overlay-change", Fnext_overlay_change, Snext_overlay_change,
endpos = oendpos; endpos = oendpos;
} }
free (overlay_vec); xfree (overlay_vec);
return make_number (endpos); return make_number (endpos);
} }
......
...@@ -285,26 +285,26 @@ free_frame_glyphs (frame, glyphs) ...@@ -285,26 +285,26 @@ free_frame_glyphs (frame, glyphs)
struct frame_glyphs *glyphs; struct frame_glyphs *glyphs;
{ {
if (glyphs->total_contents) if (glyphs->total_contents)
free (glyphs->total_contents); xfree (glyphs->total_contents);
free (glyphs->used); xfree (glyphs->used);
free (glyphs->glyphs); xfree (glyphs->glyphs);
free (glyphs->highlight); xfree (glyphs->highlight);
free (glyphs->enable); xfree (glyphs->enable);
free (glyphs->bufp); xfree (glyphs->bufp);
#ifdef HAVE_X_WINDOWS #ifdef HAVE_X_WINDOWS
if (FRAME_X_P (frame)) if (FRAME_X_P (frame))
{ {
free (glyphs->top_left_x); xfree (glyphs->top_left_x);
free (glyphs->top_left_y); xfree (glyphs->top_left_y);
free (glyphs->pix_width); xfree (glyphs->pix_width);
free (glyphs->pix_height); xfree (glyphs->pix_height);
free (glyphs->max_ascent); xfree (glyphs->max_ascent);
} }
#endif #endif
free (glyphs); xfree (glyphs);
} }
static void static void
......
...@@ -512,7 +512,7 @@ thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ int ...@@ -512,7 +512,7 @@ thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ int
tem = make_string (buf, bufp - buf); tem = make_string (buf, bufp - buf);
else else
tem = str; tem = str;
free (buf); xfree (buf);
RETURN_UNGCPRO (tem); RETURN_UNGCPRO (tem);
} }
......
...@@ -178,7 +178,7 @@ doprnt (buffer, bufsize, format, format_end, nargs, args) ...@@ -178,7 +178,7 @@ doprnt (buffer, bufsize, format, format_end, nargs, args)
/* If we had to malloc something, free it. */ /* If we had to malloc something, free it. */
if (big_buffer) if (big_buffer)
free (big_buffer); xfree (big_buffer);
*bufptr = 0; /* Make sure our string end with a '\0' */ *bufptr = 0; /* Make sure our string end with a '\0' */
return bufptr - buffer; return bufptr - buffer;
......
...@@ -311,7 +311,14 @@ main (argc, argv, envp) ...@@ -311,7 +311,14 @@ main (argc, argv, envp)
#ifndef SYSTEM_MALLOC #ifndef SYSTEM_MALLOC
if (! initialized) if (! initialized)
memory_warnings (0, malloc_warning); {
/* Arrange to get warning messages as memory fills up. */
memory_warnings (0, malloc_warning);
/* Arrange to disable interrupt input while malloc and friends are
running. */
uninterrupt_malloc ();
}
#endif /* not SYSTEM_MALLOC */ #endif /* not SYSTEM_MALLOC */
#ifdef PRIO_PROCESS #ifdef PRIO_PROCESS
......
...@@ -20,9 +20,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ ...@@ -20,9 +20,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "config.h" #include "config.h"
#include "lisp.h" #include "lisp.h"
#ifdef HAVE_X_WINDOWS #include "blockinput.h"
#include "xterm.h"
#endif
#ifndef standalone #ifndef standalone
#include "commands.h" #include "commands.h"
......
...@@ -2046,16 +2046,16 @@ Otherwise returns NIL.") ...@@ -2046,16 +2046,16 @@ Otherwise returns NIL.")
valsize = readlink (XSTRING (filename)->data, buf, bufsize); valsize = readlink (XSTRING (filename)->data, buf, bufsize);
if (valsize < bufsize) break; if (valsize < bufsize) break;
/* Buffer was not long enough */ /* Buffer was not long enough */
free (buf); xfree (buf);
bufsize *= 2; bufsize *= 2;
} }
if (valsize == -1) if (valsize == -1)
{ {
free (buf); xfree (buf);
return Qnil; return Qnil;
} }
val = make_string (buf, valsize); val = make_string (buf, valsize);
free (buf); xfree (buf);
return val; return val;
#else /* not S_IFLNK */ #else /* not S_IFLNK */
return Qnil; return Qnil;
......
...@@ -79,7 +79,7 @@ typedef int (*FUNC)(); /* pointer to a function */ ...@@ -79,7 +79,7 @@ typedef int (*FUNC)(); /* pointer to a function */
static int hfqry(); static int hfqry();
static int hfskbd(); static int hfskbd();
char *malloc(); char *xmalloc();
extern int errno; extern int errno;
static jmp_buf hftenv; static jmp_buf hftenv;
...@@ -319,7 +319,7 @@ WR_REQ (fd, request, cmdlen, cmd, resplen) ...@@ -319,7 +319,7 @@ WR_REQ (fd, request, cmdlen, cmd, resplen)
if (cmdlen) /* if arg structure to pass */ if (cmdlen) /* if arg structure to pass */
{ {
size = sizeof (struct hfctlreq) + cmdlen; size = sizeof (struct hfctlreq) + cmdlen;
if ((p.c = malloc(size)) == NULL) /* malloc one area */ if ((p.c = xmalloc(size)) == NULL) /* malloc one area */
return (-1); return (-1);
memcpy (p.c, &req, sizeof (req)); /* copy CTL REQ struct */ memcpy (p.c, &req, sizeof (req)); /* copy CTL REQ struct */
...@@ -334,7 +334,7 @@ WR_REQ (fd, request, cmdlen, cmd, resplen) ...@@ -334,7 +334,7 @@ WR_REQ (fd, request, cmdlen, cmd, resplen)
/* write request to terminal */ /* write request to terminal */
if (write(fd,p.c,size) == -1) return (-1); if (write(fd,p.c,size) == -1) return (-1);
if (p.req != &req) /* free if allocated */ if (p.req != &req) /* free if allocated */
free (p.c); xfree (p.c);
return (0); return (0);
} }
...@@ -245,7 +245,10 @@ make_gap (increment) ...@@ -245,7 +245,10 @@ make_gap (increment)
/* If we have to get more space, get enough to last a while. */ /* If we have to get more space, get enough to last a while. */
increment += 2000; increment += 2000;
BLOCK_INPUT;
result = BUFFER_REALLOC (BEG_ADDR, (Z - BEG + GAP_SIZE + increment)); result = BUFFER_REALLOC (BEG_ADDR, (Z - BEG + GAP_SIZE + increment));
UNBLOCK_INPUT;
if (result == 0) if (result == 0)
memory_full (); memory_full ();
BEG_ADDR = result; BEG_ADDR = result;
......
...@@ -36,6 +36,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ ...@@ -36,6 +36,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "dispextern.h" #include "dispextern.h"
#include "keyboard.h" #include "keyboard.h"
#include "intervals.h" #include "intervals.h"
#include "blockinput.h"
#include <setjmp.h> #include <setjmp.h>
#include <errno.h> #include <errno.h>