[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs/src term.c
From: |
Chong Yidong |
Subject: |
[Emacs-diffs] emacs/src term.c |
Date: |
Mon, 08 Dec 2008 14:44:31 +0000 |
CVSROOT: /sources/emacs
Module name: emacs
Changes by: Chong Yidong <cyd> 08/12/08 14:44:31
Modified files:
src : term.c
Log message:
(encode_terminal_code): Free any previous memory blocks
before calling xmalloc for encode_terminal_src or
encode_terminal_dst.
(maybe_fatal): Buffer argument deleted. Don't free buffer here.
All callers changed.
(init_tty): Store termcap data and string buffers in new struct
tty members termcap_term_buffer and termcap_strings_buffer.
(delete_tty): Free them.
(syms_of_term): Initialize encode_terminal_src and
encode_terminal_dst.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/src/term.c?cvsroot=emacs&r1=1.229&r2=1.230
Patches:
Index: term.c
===================================================================
RCS file: /sources/emacs/emacs/src/term.c,v
retrieving revision 1.229
retrieving revision 1.230
diff -u -b -r1.229 -r1.230
--- term.c 27 Sep 2008 10:50:48 -0000 1.229
+++ term.c 8 Dec 2008 14:44:30 -0000 1.230
@@ -581,10 +581,10 @@
required = MAX_MULTIBYTE_LENGTH * src_len;
if (encode_terminal_src_size < required)
{
- if (encode_terminal_src_size == 0)
- encode_terminal_src = xmalloc (required);
- else
+ if (encode_terminal_src)
encode_terminal_src = xrealloc (encode_terminal_src, required);
+ else
+ encode_terminal_src = xmalloc (required);
encode_terminal_src_size = required;
}
@@ -740,6 +740,10 @@
if (encode_terminal_dst_size == 0)
{
encode_terminal_dst_size = encode_terminal_src_size;
+ if (encode_terminal_dst)
+ encode_terminal_dst = xrealloc (encode_terminal_dst,
+ encode_terminal_dst_size);
+ else
encode_terminal_dst = xmalloc (encode_terminal_dst_size);
}
coding->destination = encode_terminal_dst;
@@ -3326,7 +3330,6 @@
{
char *area = NULL;
char **address = &area;
- char *buffer = NULL;
int buffer_size = 4096;
register char *p = NULL;
int status;
@@ -3335,7 +3338,7 @@
int ctty = 0; /* 1 if asked to open controlling tty. */
if (!terminal_type)
- maybe_fatal (must_succeed, 0, 0,
+ maybe_fatal (must_succeed, 0,
"Unknown terminal type",
"Unknown terminal type");
@@ -3356,7 +3359,7 @@
terminal = create_terminal ();
#ifdef MSDOS
if (been_here > 0)
- maybe_fatal (1, 0, 0, "Attempt to create another terminal %s", "",
+ maybe_fatal (1, 0, "Attempt to create another terminal %s", "",
name, "");
been_here = 1;
tty = &the_only_display_info;
@@ -3397,14 +3400,14 @@
#endif /* O_IGNORE_CTTY */
if (fd < 0)
- maybe_fatal (must_succeed, buffer, terminal,
+ maybe_fatal (must_succeed, terminal,
"Could not open file: %s",
"Could not open file: %s",
name);
if (!isatty (fd))
{
close (fd);
- maybe_fatal (must_succeed, buffer, terminal,
+ maybe_fatal (must_succeed, terminal,
"Not a tty device: %s",
"Not a tty device: %s",
name);
@@ -3504,22 +3507,22 @@
Wcm_clear (tty);
- buffer = (char *) xmalloc (buffer_size);
+ tty->termcap_term_buffer = (char *) xmalloc (buffer_size);
/* On some systems, tgetent tries to access the controlling
terminal. */
sigblock (sigmask (SIGTTOU));
- status = tgetent (buffer, terminal_type);
+ status = tgetent (tty->termcap_term_buffer, terminal_type);
sigunblock (sigmask (SIGTTOU));
if (status < 0)
{
#ifdef TERMINFO
- maybe_fatal (must_succeed, buffer, terminal,
+ maybe_fatal (must_succeed, terminal,
"Cannot open terminfo database file",
"Cannot open terminfo database file");
#else
- maybe_fatal (must_succeed, buffer, terminal,
+ maybe_fatal (must_succeed, terminal,
"Cannot open termcap database file",
"Cannot open termcap database file");
#endif
@@ -3527,7 +3530,7 @@
if (status == 0)
{
#ifdef TERMINFO
- maybe_fatal (must_succeed, buffer, terminal,
+ maybe_fatal (must_succeed, terminal,
"Terminal type %s is not defined",
"Terminal type %s is not defined.\n\
If that is not the actual type of terminal you have,\n\
@@ -3536,7 +3539,7 @@
to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.",
terminal_type);
#else
- maybe_fatal (must_succeed, buffer, terminal,
+ maybe_fatal (must_succeed, terminal,
"Terminal type %s is not defined",
"Terminal type %s is not defined.\n\
If that is not the actual type of terminal you have,\n\
@@ -3548,12 +3551,11 @@
}
#ifndef TERMINFO
- if (strlen (buffer) >= buffer_size)
+ if (strlen (tty->termcap_term_buffer) >= buffer_size)
abort ();
- buffer_size = strlen (buffer);
+ buffer_size = strlen (tty->termcap_term_buffer);
#endif
- area = (char *) xmalloc (buffer_size);
-
+ tty->termcap_strings_buffer = area = (char *) xmalloc (buffer_size);
tty->TS_ins_line = tgetstr ("al", address);
tty->TS_ins_multi_lines = tgetstr ("AL", address);
tty->TS_bell = tgetstr ("bl", address);
@@ -3690,7 +3692,7 @@
FrameRows (tty) = tgetnum ("li");
if (FrameRows (tty) < 3 || FrameCols (tty) < 3)
- maybe_fatal (must_succeed, NULL, terminal,
+ maybe_fatal (must_succeed, terminal,
"Screen size %dx%d is too small"
"Screen size %dx%d is too small",
FrameCols (tty), FrameRows (tty));
@@ -3814,7 +3816,7 @@
if (Wcm_init (tty) == -1) /* can't do cursor motion */
{
- maybe_fatal (must_succeed, NULL, terminal,
+ maybe_fatal (must_succeed, terminal,
"Terminal type \"%s\" is not powerful enough to run Emacs",
# ifdef TERMINFO
"Terminal type \"%s\" is not powerful enough to run
Emacs.\n\
@@ -3835,7 +3837,7 @@
}
if (FrameRows (tty) <= 0 || FrameCols (tty) <= 0)
- maybe_fatal (must_succeed, NULL, terminal,
+ maybe_fatal (must_succeed, terminal,
"Could not determine the frame size",
"Could not determine the frame size");
@@ -3868,9 +3870,6 @@
init_baud_rate (fileno (tty->input));
- /* Don't do this. I think termcap may still need the buffer. */
- /* xfree (buffer); */
-
#endif /* not DOS_NT */
/* Init system terminal modes (RAW or CBREAK, etc.). */
@@ -3880,18 +3879,15 @@
}
/* Auxiliary error-handling function for init_tty.
- Free BUFFER and delete TERMINAL, then call error or fatal
- with str1 or str2, respectively, according to MUST_SUCCEED. */
+ Delete TERMINAL, then call error or fatal with str1 or str2,
+ respectively, according to MUST_SUCCEED. */
static void
-maybe_fatal (must_succeed, buffer, terminal, str1, str2, arg1, arg2)
+maybe_fatal (must_succeed, terminal, str1, str2, arg1, arg2)
int must_succeed;
- char *buffer;
struct terminal *terminal;
char *str1, *str2, *arg1, *arg2;
{
- xfree (buffer);
-
if (terminal)
delete_tty (terminal);
@@ -3989,6 +3985,10 @@
xfree (tty->old_tty);
xfree (tty->Wcm);
+ if (tty->termcap_strings_buffer)
+ xfree (tty->termcap_strings_buffer);
+ if (tty->termcap_term_buffer)
+ xfree (tty->termcap_term_buffer);
bzero (tty, sizeof (struct tty_display_info));
xfree (tty);
@@ -4061,6 +4061,9 @@
default_set_foreground = NULL;
default_set_background = NULL;
#endif /* !DOS_NT */
+
+ encode_terminal_src = NULL;
+ encode_terminal_dst = NULL;
}
- [Emacs-diffs] emacs/src term.c,
Chong Yidong <=