changeset 34363:62a349fc3d3c

(Fsubstitute_command_keys): Change the way buffers are reallocated so that it is portable.
author Gerd Moellmann <gerd@gnu.org>
date Fri, 08 Dec 2000 09:59:52 +0000
parents 020c1a0abaf6
children 243429d5e6d2
files src/doc.c
diffstat 1 files changed, 15 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/doc.c	Fri Dec 08 09:59:34 2000 +0000
+++ b/src/doc.c	Fri Dec 08 09:59:52 2000 +0000
@@ -313,6 +313,8 @@
   Lisp_Object funcar;
   Lisp_Object tem, doc;
 
+  doc = Qnil;
+  
   if (SYMBOLP (function)
       && (tem = Fget (function, Qfunction_documentation),
 	  !NILP (tem)))
@@ -587,7 +589,6 @@
   register unsigned char *bufp;
   int idx;
   int bsize;
-  unsigned char *new;
   Lisp_Object tem;
   Lisp_Object keymap;
   unsigned char *start;
@@ -686,9 +687,9 @@
 
 	  if (NILP (tem))	/* but not on any keys */
 	    {
-	      new = (unsigned char *) xrealloc (buf, bsize += 4);
-	      bufp += new - buf;
-	      buf = new;
+	      int offset = bufp - buf;
+	      buf = (unsigned char *) xrealloc (buf, bsize += 4);
+	      bufp = buf + offset;
 	      bcopy ("M-x ", bufp, 4);
 	      bufp += 4;
 	      nchars += 4;
@@ -771,14 +772,16 @@
 	  length = XSTRING (tem)->size;
 	  length_byte = STRING_BYTES (XSTRING (tem));
 	subst:
-	  new = (unsigned char *) xrealloc (buf, bsize += length_byte);
-	  bufp += new - buf;
-	  buf = new;
-	  bcopy (start, bufp, length_byte);
-	  bufp += length_byte;
-	  nchars += length;
-	  /* Check STRING again in case gc relocated it.  */
-	  strp = (unsigned char *) XSTRING (string)->data + idx;
+	  {
+	    int offset = bufp - buf;
+	    buf = (unsigned char *) xrealloc (buf, bsize += length_byte);
+	    bufp = buf + offset;
+	    bcopy (start, bufp, length_byte);
+	    bufp += length_byte;
+	    nchars += length;
+	    /* Check STRING again in case gc relocated it.  */
+	    strp = (unsigned char *) XSTRING (string)->data + idx;
+	  }
 	}
       else if (! multibyte)		/* just copy other chars */
 	*bufp++ = *strp++, nchars++;