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

src/termcap.c

index f802704383ce939517d1f9fde424e24f61110d1b..c9bf1a40b52214a24f69f4b72c80fbcfb2bd3fe9 100644 (file)
@@ -555,11 +555,11 @@ tgetent (bp, name)
       /* If BP is malloc'd by us, make sure it is big enough.  */
       if (malloc_size)
        {
-         malloc_size = bp1 - bp + buf.size;
-         termcap_name = (char *) xrealloc (bp, malloc_size);
-         bp1 += termcap_name - bp;
-         tc_search_point += termcap_name - bp;
-         bp = termcap_name;
+         int offset1 = bp1 - bp, offset2 = tc_search_point - bp;
+         malloc_size = offset1 + buf.size;
+         bp = termcap_name = (char *) xrealloc (bp, malloc_size);
+         bp1 = termcap_name + offset1;
+         tc_search_point = termcap_name + offset2;
        }
 
       /* Copy the line of the entry from buf into bp.  */