]> git.eshelyaron.com Git - emacs.git/commitdiff
(tparam1): Change the way buffers are reallocated to be
authorGerd Moellmann <gerd@gnu.org>
Fri, 8 Dec 2000 09:58:48 +0000 (09:58 +0000)
committerGerd Moellmann <gerd@gnu.org>
Fri, 8 Dec 2000 09:58:48 +0000 (09:58 +0000)
portable and less obfuscated.

src/tparam.c

index 7d3752713faf16fdbe94a7b4b71141f8dd440a88..0548c722198ce2d260e8025c6cd574b3253b5e1e 100644 (file)
@@ -1,5 +1,5 @@
 /* Merge parameters into a termcap entry string.
-   Copyright (C) 1985, 87, 93, 95 Free Software Foundation, Inc.
+   Copyright (C) 1985, 87, 93, 95, 2000 Free Software Foundation, Inc.
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -150,21 +150,22 @@ tparam1 (string, outstring, len, up, left, argp)
       if (op + 5 >= outend)
        {
          register char *new;
+         int offset = op - outstring;
+
          if (outlen == 0)
            {
              outlen = len + 40;
              new = (char *) xmalloc (outlen);
-             outend += 40;
-             bcopy (outstring, new, op - outstring);
+             bcopy (outstring, new, offset);
            }
          else
            {
-             outend += outlen;
              outlen *= 2;
              new = (char *) xrealloc (outstring, outlen);
            }
-         op += new - outstring;
-         outend += new - outstring;
+         
+         op = new + offset;
+         outend = new + outlen;
          outstring = new;
        }
       c = *p++;