comparison src/fileio.c @ 17820:d7b187832881

(Finsert_file_contents): Use xmalloc. not malloc. Check correctly for whether no code translation is needed.
author Richard M. Stallman <rms@gnu.org>
date Thu, 15 May 1997 20:15:56 +0000
parents f67a321c8fb6
children 2f313f045caa
comparison
equal deleted inserted replaced
17819:6fd66459ec9a 17820:d7b187832881
3164 But if we discover the need for conversion, we give up on this method 3164 But if we discover the need for conversion, we give up on this method
3165 and let the following if-statement handle the replace job. */ 3165 and let the following if-statement handle the replace job. */
3166 if (!NILP (replace) 3166 if (!NILP (replace)
3167 && (! CODING_REQUIRE_CONVERSION (&coding) 3167 && (! CODING_REQUIRE_CONVERSION (&coding)
3168 || (coding.type == coding_type_automatic 3168 || (coding.type == coding_type_automatic
3169 && ! CODING_REQUIRE_TEXT_CONVERSION (&coding)) 3169 && ! CODING_REQUIRE_EOL_CONVERSION (&coding))
3170 || (coding.eol_type == CODING_EOL_AUTOMATIC 3170 || (coding.eol_type == CODING_EOL_AUTOMATIC
3171 && ! CODING_REQUIRE_EOL_CONVERSION (&coding)))) 3171 && ! CODING_REQUIRE_TEXT_CONVERSION (&coding))))
3172 { 3172 {
3173 int same_at_start = BEGV; 3173 int same_at_start = BEGV;
3174 int same_at_end = ZV; 3174 int same_at_end = ZV;
3175 int overlap; 3175 int overlap;
3176 /* There is still a possibility we will find the need to do code 3176 /* There is still a possibility we will find the need to do code
3334 int same_at_end = ZV; 3334 int same_at_end = ZV;
3335 int overlap; 3335 int overlap;
3336 int bufpos; 3336 int bufpos;
3337 /* Make sure that the gap is large enough. */ 3337 /* Make sure that the gap is large enough. */
3338 int bufsize = 2 * st.st_size; 3338 int bufsize = 2 * st.st_size;
3339 unsigned char *conversion_buffer = (unsigned char *) malloc (bufsize); 3339 unsigned char *conversion_buffer = (unsigned char *) xmalloc (bufsize);
3340 3340
3341 /* First read the whole file, performing code conversion into 3341 /* First read the whole file, performing code conversion into
3342 CONVERSION_BUFFER. */ 3342 CONVERSION_BUFFER. */
3343 3343
3344 if (lseek (fd, XINT (beg), 0) < 0) 3344 if (lseek (fd, XINT (beg), 0) < 0)