aboutsummaryrefslogtreecommitdiffstats
path: root/src/charset.c
diff options
context:
space:
mode:
authorPaul Eggert2011-09-30 10:44:37 -0700
committerPaul Eggert2011-09-30 10:44:37 -0700
commit535272bb73eff5a5db01301e5b60f6128d6dc788 (patch)
treeb41937c81a61bf737ef15efb434fc06338da25b4 /src/charset.c
parent38532ce6ecb33efee5f697886d9fd20a3c2cda01 (diff)
parentf701dc2abbcfb64c0c4d02ac899dccb03ee2b246 (diff)
downloademacs-535272bb73eff5a5db01301e5b60f6128d6dc788.tar.gz
emacs-535272bb73eff5a5db01301e5b60f6128d6dc788.zip
Merge from trunk.
Diffstat (limited to 'src/charset.c')
-rw-r--r--src/charset.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/charset.c b/src/charset.c
index 2451c55e92a..299655b2cf8 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1154,10 +1154,10 @@ usage: (define-charset-internal ...) */)
1154 sizeof *charset_table); 1154 sizeof *charset_table);
1155 memcpy (new_table, charset_table, old_size * sizeof *new_table); 1155 memcpy (new_table, charset_table, old_size * sizeof *new_table);
1156 charset_table = new_table; 1156 charset_table = new_table;
1157 /* FIXME: Doesn't this leak memory? The old charset_table becomes 1157 /* FIXME: This leaks memory, as the old charset_table becomes
1158 unreachable. It could be that this is intentional, because the 1158 unreachable. If the old charset table is charset_table_init
1159 old charset table may be in a dumped emacs, and reallocating such 1159 then this leak is intentional; otherwise, it's unclear.
1160 a table may not work. If the memory leak is intentional, a 1160 If the latter memory leak is intentional, a
1161 comment should be added to explain this. If not, the old 1161 comment should be added to explain this. If not, the old
1162 charset_table should be freed, by passing it as the 1st argument 1162 charset_table should be freed, by passing it as the 1st argument
1163 to xpalloc and removing the memcpy. */ 1163 to xpalloc and removing the memcpy. */
@@ -2318,20 +2318,21 @@ init_charset_once (void)
2318 2318
2319#ifdef emacs 2319#ifdef emacs
2320 2320
2321/* Allocate an initial charset table that is large enough to handle
2322 Emacs while it is bootstrapping. As of September 2011, the size
2323 needs to be at least 166; make it a bit bigger to allow for future
2324 expansion.
2325
2326 Don't make the value so small that the table is reallocated during
2327 bootstrapping, as glibc malloc calls larger than just under 64 KiB
2328 during an initial bootstrap wreak havoc after dumping; see the
2329 M_MMAP_THRESHOLD value in alloc.c, plus there is a extra overhead
2330 internal to glibc malloc and perhaps to Emacs malloc debugging. */
2331static struct charset charset_table_init[180];
2332
2321void 2333void
2322syms_of_charset (void) 2334syms_of_charset (void)
2323{ 2335{
2324 /* Allocate an initial charset table that is just under 64 KiB in size.
2325 This should be large enough so that the charset table need not be
2326 reallocated during an initial bootstrap. Allocating anything larger than
2327 64 KiB in an initial run may not work, because glibc malloc might use
2328 mmap for larger allocations, and these don't work well across dumped
2329 systems. */
2330 enum {
2331 initial_malloc_max = (1 << 16) - 1,
2332 charset_table_size_init = initial_malloc_max / sizeof (struct charset)
2333 };
2334
2335 DEFSYM (Qcharsetp, "charsetp"); 2336 DEFSYM (Qcharsetp, "charsetp");
2336 2337
2337 DEFSYM (Qascii, "ascii"); 2338 DEFSYM (Qascii, "ascii");
@@ -2364,9 +2365,8 @@ syms_of_charset (void)
2364 Vcharset_hash_table = Fmake_hash_table (2, args); 2365 Vcharset_hash_table = Fmake_hash_table (2, args);
2365 } 2366 }
2366 2367
2367 charset_table = (struct charset *) xmalloc (sizeof (struct charset) 2368 charset_table = charset_table_init;
2368 * charset_table_size_init); 2369 charset_table_size = sizeof charset_table_init / sizeof *charset_table_init;
2369 charset_table_size = charset_table_size_init;
2370 charset_table_used = 0; 2370 charset_table_used = 0;
2371 2371
2372 defsubr (&Scharsetp); 2372 defsubr (&Scharsetp);