aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerd Moellmann2000-12-08 09:58:48 +0000
committerGerd Moellmann2000-12-08 09:58:48 +0000
commitb5e55477b39213d5390d0f6a05afa85e9b05b7ea (patch)
tree51c140a6f37dc06af29ee270cc21eaf937eb4da7 /src
parentee89188f2926b9e651d488dea8841cccc571a1fe (diff)
downloademacs-b5e55477b39213d5390d0f6a05afa85e9b05b7ea.tar.gz
emacs-b5e55477b39213d5390d0f6a05afa85e9b05b7ea.zip
(tparam1): Change the way buffers are reallocated to be
portable and less obfuscated.
Diffstat (limited to 'src')
-rw-r--r--src/tparam.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/tparam.c b/src/tparam.c
index 7d3752713fa..0548c722198 100644
--- a/src/tparam.c
+++ b/src/tparam.c
@@ -1,5 +1,5 @@
1/* Merge parameters into a termcap entry string. 1/* Merge parameters into a termcap entry string.
2 Copyright (C) 1985, 87, 93, 95 Free Software Foundation, Inc. 2 Copyright (C) 1985, 87, 93, 95, 2000 Free Software Foundation, Inc.
3 3
4This program is free software; you can redistribute it and/or modify 4This program is free software; you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by 5it under the terms of the GNU General Public License as published by
@@ -150,21 +150,22 @@ tparam1 (string, outstring, len, up, left, argp)
150 if (op + 5 >= outend) 150 if (op + 5 >= outend)
151 { 151 {
152 register char *new; 152 register char *new;
153 int offset = op - outstring;
154
153 if (outlen == 0) 155 if (outlen == 0)
154 { 156 {
155 outlen = len + 40; 157 outlen = len + 40;
156 new = (char *) xmalloc (outlen); 158 new = (char *) xmalloc (outlen);
157 outend += 40; 159 bcopy (outstring, new, offset);
158 bcopy (outstring, new, op - outstring);
159 } 160 }
160 else 161 else
161 { 162 {
162 outend += outlen;
163 outlen *= 2; 163 outlen *= 2;
164 new = (char *) xrealloc (outstring, outlen); 164 new = (char *) xrealloc (outstring, outlen);
165 } 165 }
166 op += new - outstring; 166
167 outend += new - outstring; 167 op = new + offset;
168 outend = new + outlen;
168 outstring = new; 169 outstring = new;
169 } 170 }
170 c = *p++; 171 c = *p++;