aboutsummaryrefslogtreecommitdiffstats
path: root/src/ralloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ralloc.c')
-rw-r--r--src/ralloc.c68
1 files changed, 23 insertions, 45 deletions
diff --git a/src/ralloc.c b/src/ralloc.c
index 7ccbdc7daf7..dd68e7c8afc 100644
--- a/src/ralloc.c
+++ b/src/ralloc.c
@@ -40,11 +40,11 @@ typedef size_t SIZE;
40/* Declared in dispnew.c, this version doesn't screw up if regions 40/* Declared in dispnew.c, this version doesn't screw up if regions
41 overlap. */ 41 overlap. */
42 42
43extern void safe_bcopy (); 43extern void safe_bcopy (const char *, char *, int);
44 44
45#ifdef DOUG_LEA_MALLOC 45#ifdef DOUG_LEA_MALLOC
46#define M_TOP_PAD -2 46#define M_TOP_PAD -2
47extern int mallopt (); 47extern int mallopt (int, int);
48#else /* not DOUG_LEA_MALLOC */ 48#else /* not DOUG_LEA_MALLOC */
49#ifndef SYSTEM_MALLOC 49#ifndef SYSTEM_MALLOC
50extern size_t __malloc_extra_blocks; 50extern size_t __malloc_extra_blocks;
@@ -81,7 +81,7 @@ typedef void *POINTER;
81 81
82static int r_alloc_initialized = 0; 82static int r_alloc_initialized = 0;
83 83
84static void r_alloc_init (); 84static void r_alloc_init (void);
85 85
86 86
87/* Declarations for working with the malloc, ralloc, and system breaks. */ 87/* Declarations for working with the malloc, ralloc, and system breaks. */
@@ -210,8 +210,7 @@ static int r_alloc_freeze_level;
210/* Find the heap that ADDRESS falls within. */ 210/* Find the heap that ADDRESS falls within. */
211 211
212static heap_ptr 212static heap_ptr
213find_heap (address) 213find_heap (POINTER address)
214 POINTER address;
215{ 214{
216 heap_ptr heap; 215 heap_ptr heap;
217 216
@@ -243,9 +242,7 @@ find_heap (address)
243 allocate the memory. */ 242 allocate the memory. */
244 243
245static POINTER 244static POINTER
246obtain (address, size) 245obtain (POINTER address, SIZE size)
247 POINTER address;
248 SIZE size;
249{ 246{
250 heap_ptr heap; 247 heap_ptr heap;
251 SIZE already_available; 248 SIZE already_available;
@@ -326,7 +323,7 @@ obtain (address, size)
326 it can also eliminate the last heap entirely. */ 323 it can also eliminate the last heap entirely. */
327 324
328static void 325static void
329relinquish () 326relinquish (void)
330{ 327{
331 register heap_ptr h; 328 register heap_ptr h;
332 long excess = 0; 329 long excess = 0;
@@ -385,7 +382,7 @@ relinquish ()
385 above where malloc gets space. */ 382 above where malloc gets space. */
386 383
387long 384long
388r_alloc_size_in_use () 385r_alloc_size_in_use (void)
389{ 386{
390 return (char *) break_value - (char *) virtual_break_value; 387 return (char *) break_value - (char *) virtual_break_value;
391} 388}
@@ -396,8 +393,7 @@ r_alloc_size_in_use ()
396 to that block. */ 393 to that block. */
397 394
398static bloc_ptr 395static bloc_ptr
399find_bloc (ptr) 396find_bloc (POINTER *ptr)
400 POINTER *ptr;
401{ 397{
402 register bloc_ptr p = first_bloc; 398 register bloc_ptr p = first_bloc;
403 399
@@ -422,8 +418,7 @@ find_bloc (ptr)
422 memory for the new block. */ 418 memory for the new block. */
423 419
424static bloc_ptr 420static bloc_ptr
425get_bloc (size) 421get_bloc (SIZE size)
426 SIZE size;
427{ 422{
428 register bloc_ptr new_bloc; 423 register bloc_ptr new_bloc;
429 register heap_ptr heap; 424 register heap_ptr heap;
@@ -478,10 +473,7 @@ get_bloc (size)
478 Do not touch the contents of blocs or break_value. */ 473 Do not touch the contents of blocs or break_value. */
479 474
480static int 475static int
481relocate_blocs (bloc, heap, address) 476relocate_blocs (bloc_ptr bloc, heap_ptr heap, POINTER address)
482 bloc_ptr bloc;
483 heap_ptr heap;
484 POINTER address;
485{ 477{
486 register bloc_ptr b = bloc; 478 register bloc_ptr b = bloc;
487 479
@@ -541,8 +533,7 @@ relocate_blocs (bloc, heap, address)
541 before that of BEFORE. */ 533 before that of BEFORE. */
542 534
543static void 535static void
544reorder_bloc (bloc, before) 536reorder_bloc (bloc_ptr bloc, bloc_ptr before)
545 bloc_ptr bloc, before;
546{ 537{
547 bloc_ptr prev, next; 538 bloc_ptr prev, next;
548 539
@@ -570,9 +561,7 @@ reorder_bloc (bloc, before)
570 with heap HEAP and bloc BLOC. */ 561 with heap HEAP and bloc BLOC. */
571 562
572static void 563static void
573update_heap_bloc_correspondence (bloc, heap) 564update_heap_bloc_correspondence (bloc_ptr bloc, heap_ptr heap)
574 bloc_ptr bloc;
575 heap_ptr heap;
576{ 565{
577 register bloc_ptr b; 566 register bloc_ptr b;
578 567
@@ -634,9 +623,7 @@ update_heap_bloc_correspondence (bloc, heap)
634 that come after BLOC in memory. */ 623 that come after BLOC in memory. */
635 624
636static int 625static int
637resize_bloc (bloc, size) 626resize_bloc (bloc_ptr bloc, SIZE size)
638 bloc_ptr bloc;
639 SIZE size;
640{ 627{
641 register bloc_ptr b; 628 register bloc_ptr b;
642 heap_ptr heap; 629 heap_ptr heap;
@@ -733,8 +720,7 @@ resize_bloc (bloc, size)
733 This may return space to the system. */ 720 This may return space to the system. */
734 721
735static void 722static void
736free_bloc (bloc) 723free_bloc (bloc_ptr bloc)
737 bloc_ptr bloc;
738{ 724{
739 heap_ptr heap = bloc->heap; 725 heap_ptr heap = bloc->heap;
740 726
@@ -800,8 +786,7 @@ free_bloc (bloc)
800 GNU malloc package. */ 786 GNU malloc package. */
801 787
802POINTER 788POINTER
803r_alloc_sbrk (size) 789r_alloc_sbrk (long int size)
804 long size;
805{ 790{
806 register bloc_ptr b; 791 register bloc_ptr b;
807 POINTER address; 792 POINTER address;
@@ -952,9 +937,7 @@ r_alloc_sbrk (size)
952 return zero. */ 937 return zero. */
953 938
954POINTER 939POINTER
955r_alloc (ptr, size) 940r_alloc (POINTER *ptr, SIZE size)
956 POINTER *ptr;
957 SIZE size;
958{ 941{
959 register bloc_ptr new_bloc; 942 register bloc_ptr new_bloc;
960 943
@@ -977,8 +960,7 @@ r_alloc (ptr, size)
977 Store 0 in *PTR to show there's no block allocated. */ 960 Store 0 in *PTR to show there's no block allocated. */
978 961
979void 962void
980r_alloc_free (ptr) 963r_alloc_free (register POINTER *ptr)
981 register POINTER *ptr;
982{ 964{
983 register bloc_ptr dead_bloc; 965 register bloc_ptr dead_bloc;
984 966
@@ -1012,9 +994,7 @@ r_alloc_free (ptr)
1012 return zero. */ 994 return zero. */
1013 995
1014POINTER 996POINTER
1015r_re_alloc (ptr, size) 997r_re_alloc (POINTER *ptr, SIZE size)
1016 POINTER *ptr;
1017 SIZE size;
1018{ 998{
1019 register bloc_ptr bloc; 999 register bloc_ptr bloc;
1020 1000
@@ -1075,8 +1055,7 @@ r_re_alloc (ptr, size)
1075 malloc must return a null pointer. */ 1055 malloc must return a null pointer. */
1076 1056
1077void 1057void
1078r_alloc_freeze (size) 1058r_alloc_freeze (long int size)
1079 long size;
1080{ 1059{
1081 if (! r_alloc_initialized) 1060 if (! r_alloc_initialized)
1082 r_alloc_init (); 1061 r_alloc_init ();
@@ -1093,7 +1072,7 @@ r_alloc_freeze (size)
1093} 1072}
1094 1073
1095void 1074void
1096r_alloc_thaw () 1075r_alloc_thaw (void)
1097{ 1076{
1098 1077
1099 if (! r_alloc_initialized) 1078 if (! r_alloc_initialized)
@@ -1122,7 +1101,7 @@ r_alloc_thaw ()
1122/* Reinitialize the morecore hook variables after restarting a dumped 1101/* Reinitialize the morecore hook variables after restarting a dumped
1123 Emacs. This is needed when using Doug Lea's malloc from GNU libc. */ 1102 Emacs. This is needed when using Doug Lea's malloc from GNU libc. */
1124void 1103void
1125r_alloc_reinit () 1104r_alloc_reinit (void)
1126{ 1105{
1127 /* Only do this if the hook has been reset, so that we don't get an 1106 /* Only do this if the hook has been reset, so that we don't get an
1128 infinite loop, in case Emacs was linked statically. */ 1107 infinite loop, in case Emacs was linked statically. */
@@ -1235,8 +1214,7 @@ r_alloc_check ()
1235 is checked to ensure that memory corruption does not occur due to 1214 is checked to ensure that memory corruption does not occur due to
1236 misuse. */ 1215 misuse. */
1237void 1216void
1238r_alloc_reset_variable (old, new) 1217r_alloc_reset_variable (POINTER *old, POINTER *new)
1239 POINTER *old, *new;
1240{ 1218{
1241 bloc_ptr bloc = first_bloc; 1219 bloc_ptr bloc = first_bloc;
1242 1220
@@ -1266,7 +1244,7 @@ r_alloc_reset_variable (old, new)
1266/* Initialize various things for memory allocation. */ 1244/* Initialize various things for memory allocation. */
1267 1245
1268static void 1246static void
1269r_alloc_init () 1247r_alloc_init (void)
1270{ 1248{
1271 if (r_alloc_initialized) 1249 if (r_alloc_initialized)
1272 return; 1250 return;