int eof;
Lisp_Object suffixes;
struct charset_map_entries *head, *entries;
- int n_entries;
- int count = SPECPDL_INDEX ();
+ int n_entries, count;
+ USE_SAFE_ALLOCA;
suffixes = Fcons (build_string (".map"),
Fcons (build_string (".TXT"), Qnil));
+ count = SPECPDL_INDEX ();
specbind (Qfile_name_handler_alist, Qnil);
fd = openp (Vcharset_map_path, mapfile, suffixes, NULL, Qnil);
unbind_to (count, Qnil);
|| ! (fp = fdopen (fd, "r")))
error ("Failure in loading charset map: %S", SDATA (mapfile));
- head = entries = ((struct charset_map_entries *)
- xmalloc (sizeof (struct charset_map_entries)));
+ /* Use SAFE_ALLOCA instead of alloca, as `charset_map_entries' is
+ large (larger than MAX_ALLOCA). */
+ SAFE_ALLOCA (head, struct charset_map_entries *,
+ sizeof (struct charset_map_entries));
+ entries = head;
+
n_entries = 0;
eof = 0;
while (1)
if (n_entries > 0 && (n_entries % 0x10000) == 0)
{
- entries->next = ((struct charset_map_entries *)
- alloca (sizeof (struct charset_map_entries)));
+ SAFE_ALLOCA (entries->next, struct charset_map_entries *,
+ sizeof (struct charset_map_entries));
entries = entries->next;
}
idx = n_entries % 0x10000;
close (fd);
load_charset_map (charset, head, n_entries, control_flag);
- xfree (head);
+ SAFE_FREE ();
}
static void
int n_entries;
int len = ASIZE (vec);
int i;
+ USE_SAFE_ALLOCA;
if (len % 2 == 1)
{
return;
}
- head = entries = ((struct charset_map_entries *)
- alloca (sizeof (struct charset_map_entries)));
+ /* Use SAFE_ALLOCA instead of alloca, as `charset_map_entries' is
+ large (larger than MAX_ALLOCA). */
+ SAFE_ALLOCA (head, struct charset_map_entries *,
+ sizeof (struct charset_map_entries));
+ entries = head;
+
n_entries = 0;
for (i = 0; i < len; i += 2)
{
if (n_entries > 0 && (n_entries % 0x10000) == 0)
{
- entries->next = ((struct charset_map_entries *)
- alloca (sizeof (struct charset_map_entries)));
+ SAFE_ALLOCA (entries->next, struct charset_map_entries *,
+ sizeof (struct charset_map_entries));
entries = entries->next;
}
idx = n_entries % 0x10000;
}
load_charset_map (charset, head, n_entries, control_flag);
+ SAFE_FREE ();
}