comparison src/mc-alloc.c @ 2723:c474585a3460

[xemacs-hg @ 2005-04-10 00:47:53 by crestani] New Allocator Fixes * dumper.c (pdump_get_mc_addr): Use clearer code. * dumper.c (pdump_put_mc_addr): Use clearer code. * emacs.c (main_1): Initialize the new allocator only once. * mc-alloc.c (get_page_header): Split up the assertions to better spot the problem. * mc-alloc.c (mc_alloc_1): Move definitions of local variables to the beginning of the function.
author crestani
date Sun, 10 Apr 2005 00:47:58 +0000
parents 6fa9919a9a0b
children 05d62157e048
comparison
equal deleted inserted replaced
2722:65bc67c9185a 2723:c474585a3460
569 static page_header * 569 static page_header *
570 get_page_header (void *ptr) 570 get_page_header (void *ptr)
571 { 571 {
572 int l1_index = L1_INDEX (ptr); 572 int l1_index = L1_INDEX (ptr);
573 level_2_lookup_tree *l2 = PTR_LOOKUP_TABLE (l1_index); 573 level_2_lookup_tree *l2 = PTR_LOOKUP_TABLE (l1_index);
574 assert (l2);
574 #ifdef USE_HASH_TABLE 575 #ifdef USE_HASH_TABLE
575 while ((l2) && (LEVEL2_KEY (l2) != l1_index)) 576 while ((l2) && (LEVEL2_KEY (l2) != l1_index))
576 l2 = LEVEL2_HASH_LINK (l2); 577 l2 = LEVEL2_HASH_LINK (l2);
577 #endif 578 #endif
578 assert (l2 && LEVEL2 (l2, L2_INDEX (ptr))); 579 assert (LEVEL2 (l2, L2_INDEX (ptr)));
579 return LEVEL2 (l2, L2_INDEX (ptr)); 580 return LEVEL2 (l2, L2_INDEX (ptr));
580 } 581 }
581 582
582 583
583 /* Returns the mark bit index of a given heap address. */ 584 /* Returns the mark bit index of a given heap address. */
1412 from the free list, if this fails, a new page is allocated. */ 1413 from the free list, if this fails, a new page is allocated. */
1413 static void * 1414 static void *
1414 mc_alloc_1 (size_t size, int managed) 1415 mc_alloc_1 (size_t size, int managed)
1415 { 1416 {
1416 page_list_header *plh = 0; 1417 page_list_header *plh = 0;
1418 page_header *ph = 0;
1419 void *result = 0;
1420
1417 if (managed) 1421 if (managed)
1418 plh = USED_HEAP_PAGES (get_used_list_index (size)); 1422 plh = USED_HEAP_PAGES (get_used_list_index (size));
1419 else 1423 else
1420 plh = UNMANAGED_HEAP_PAGES (get_unmanaged_list_index (size)); 1424 plh = UNMANAGED_HEAP_PAGES (get_unmanaged_list_index (size));
1421 1425
1422 page_header *ph = 0;
1423 void *result = 0;
1424 if (size == 0) 1426 if (size == 0)
1425 return 0; 1427 return 0;
1426 if (size < PAGE_SIZE_DIV_2) 1428 if (size < PAGE_SIZE_DIV_2)
1427 /* first check any free cells */ 1429 /* first check any free cells */
1428 ph = allocate_cell (plh); 1430 ph = allocate_cell (plh);