/[emacs]/emacs/src/data.c
ViewVC logotype

Diff of /emacs/src/data.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.224.4.4 by miles, Mon Jun 28 07:29:19 2004 UTC revision 1.224.4.5 by miles, Tue Jun 29 16:46:01 2004 UTC
# Line 1983  or a byte-code object.  IDX starts at 0. Line 1983  or a byte-code object.  IDX starts at 0.
1983      }      }
1984  }  }
1985    
 /* Don't use alloca for relocating string data larger than this, lest  
    we overflow their stack.  The value is the same as what used in  
    fns.c for base64 handling.  */  
 #define MAX_ALLOCA 16*1024  
   
1986  DEFUN ("aset", Faset, Saset, 3, 3, 0,  DEFUN ("aset", Faset, Saset, 3, 3, 0,
1987         doc: /* Store into the element of ARRAY at index IDX the value NEWELT.         doc: /* Store into the element of ARRAY at index IDX the value NEWELT.
1988  Return NEWELT.  ARRAY may be a vector, a string, a char-table or a  Return NEWELT.  ARRAY may be a vector, a string, a char-table or a
# Line 2051  bool-vector.  IDX starts at 0.  */) Line 2046  bool-vector.  IDX starts at 0.  */)
2046            /* We must relocate the string data.  */            /* We must relocate the string data.  */
2047            int nchars = SCHARS (array);            int nchars = SCHARS (array);
2048            unsigned char *str;            unsigned char *str;
2049              USE_SAFE_ALLOCA;
2050    
2051            str = (nbytes <= MAX_ALLOCA            SAFE_ALLOCA (str, unsigned char *, nbytes);
                  ? (unsigned char *) alloca (nbytes)  
                  : (unsigned char *) xmalloc (nbytes));  
2052            bcopy (SDATA (array), str, nbytes);            bcopy (SDATA (array), str, nbytes);
2053            allocate_string_data (XSTRING (array), nchars,            allocate_string_data (XSTRING (array), nchars,
2054                                  nbytes + new_bytes - prev_bytes);                                  nbytes + new_bytes - prev_bytes);
# Line 2062  bool-vector.  IDX starts at 0.  */) Line 2056  bool-vector.  IDX starts at 0.  */)
2056            p1 = SDATA (array) + idxval_byte;            p1 = SDATA (array) + idxval_byte;
2057            bcopy (str + idxval_byte + prev_bytes, p1 + new_bytes,            bcopy (str + idxval_byte + prev_bytes, p1 + new_bytes,
2058                   nbytes - (idxval_byte + prev_bytes));                   nbytes - (idxval_byte + prev_bytes));
2059            if (nbytes > MAX_ALLOCA)            SAFE_FREE (nbytes);
             xfree (str);  
2060            clear_string_char_byte_cache ();            clear_string_char_byte_cache ();
2061          }          }
2062        while (new_bytes--)        while (new_bytes--)
# Line 2086  bool-vector.  IDX starts at 0.  */) Line 2079  bool-vector.  IDX starts at 0.  */)
2079            unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *p0 = workbuf, *p1;            unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *p0 = workbuf, *p1;
2080            unsigned char *origstr = SDATA (array), *str;            unsigned char *origstr = SDATA (array), *str;
2081            int nchars, nbytes;            int nchars, nbytes;
2082              USE_SAFE_ALLOCA;
2083    
2084            nchars = SCHARS (array);            nchars = SCHARS (array);
2085            nbytes = idxval_byte = count_size_as_multibyte (origstr, idxval);            nbytes = idxval_byte = count_size_as_multibyte (origstr, idxval);
2086            nbytes += count_size_as_multibyte (origstr + idxval,            nbytes += count_size_as_multibyte (origstr + idxval,
2087                                               nchars - idxval);                                               nchars - idxval);
2088            str = (nbytes <= MAX_ALLOCA            SAFE_ALLOCA (str, unsigned char *, nbytes);
                  ? (unsigned char *) alloca (nbytes)  
                  : (unsigned char *) xmalloc (nbytes));  
2089            copy_text (SDATA (array), str, nchars, 0, 1);            copy_text (SDATA (array), str, nchars, 0, 1);
2090            PARSE_MULTIBYTE_SEQ (str + idxval_byte, nbytes - idxval_byte,            PARSE_MULTIBYTE_SEQ (str + idxval_byte, nbytes - idxval_byte,
2091                                 prev_bytes);                                 prev_bytes);
# Line 2106  bool-vector.  IDX starts at 0.  */) Line 2098  bool-vector.  IDX starts at 0.  */)
2098              *p1++ = *p0++;              *p1++ = *p0++;
2099            bcopy (str + idxval_byte + prev_bytes, p1,            bcopy (str + idxval_byte + prev_bytes, p1,
2100                   nbytes - (idxval_byte + prev_bytes));                   nbytes - (idxval_byte + prev_bytes));
2101            if (nbytes > MAX_ALLOCA)            SAFE_FREE (nbytes);
             xfree (str);  
2102            clear_string_char_byte_cache ();            clear_string_char_byte_cache ();
2103          }          }
2104      }      }

Legend:
Removed from v.1.224.4.4  
changed lines
  Added in v.1.224.4.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26