comparison src/ralloc.c @ 10747:c6a68e4ee53a

(r_alloc_free): Call refill_memory_reserve only if emacs. Include getpagesize.h unconditionally. (free_bloc): Don't die if bloc->next or bloc->prev is null. [!emacs] (bzero): New macro definition.
author Richard M. Stallman <rms@gnu.org>
date Tue, 14 Feb 1995 14:27:18 +0000
parents 5659c0885145
children 07eea2d610d3
comparison
equal deleted inserted replaced
10746:ea87e4d9c8ea 10747:c6a68e4ee53a
54 54
55 /* Declared in dispnew.c, this version doesn't screw up if regions 55 /* Declared in dispnew.c, this version doesn't screw up if regions
56 overlap. */ 56 overlap. */
57 extern void safe_bcopy (); 57 extern void safe_bcopy ();
58 58
59 #include "getpagesize.h" 59 #else /* not emacs */
60
61 #else /* Not emacs. */
62 60
63 #include <stddef.h> 61 #include <stddef.h>
64 62
65 typedef size_t SIZE; 63 typedef size_t SIZE;
66 typedef void *POINTER; 64 typedef void *POINTER;
68 #include <unistd.h> 66 #include <unistd.h>
69 #include <malloc.h> 67 #include <malloc.h>
70 #include <string.h> 68 #include <string.h>
71 69
72 #define safe_bcopy(x, y, z) memmove (y, x, z) 70 #define safe_bcopy(x, y, z) memmove (y, x, z)
73 71 #define bzero(x, len) memset (x, 0, len)
74 #endif /* emacs. */ 72
73 #endif /* not emacs */
74
75 #include "getpagesize.h"
75 76
76 #define NIL ((POINTER) 0) 77 #define NIL ((POINTER) 0)
77 78
78 /* A flag to indicate whether we have initialized ralloc yet. For 79 /* A flag to indicate whether we have initialized ralloc yet. For
79 Emacs's sake, please do not make this local to malloc_init; on some 80 Emacs's sake, please do not make this local to malloc_init; on some
689 } 690 }
690 691
691 /* Update the records of which blocs are in HEAP. */ 692 /* Update the records of which blocs are in HEAP. */
692 if (heap->first_bloc == bloc) 693 if (heap->first_bloc == bloc)
693 { 694 {
694 if (bloc->next->heap == heap) 695 if (bloc->next != 0 && bloc->next->heap == heap)
695 heap->first_bloc = bloc->next; 696 heap->first_bloc = bloc->next;
696 else 697 else
697 heap->first_bloc = heap->last_bloc = NIL_BLOC; 698 heap->first_bloc = heap->last_bloc = NIL_BLOC;
698 } 699 }
699 if (heap->last_bloc == bloc) 700 if (heap->last_bloc == bloc)
700 { 701 {
701 if (bloc->prev->heap == heap) 702 if (bloc->prev != 0 && bloc->prev->heap == heap)
702 heap->last_bloc = bloc->prev; 703 heap->last_bloc = bloc->prev;
703 else 704 else
704 heap->first_bloc = heap->last_bloc = NIL_BLOC; 705 heap->first_bloc = heap->last_bloc = NIL_BLOC;
705 } 706 }
706 707
898 abort (); 899 abort ();
899 900
900 free_bloc (dead_bloc); 901 free_bloc (dead_bloc);
901 *ptr = 0; 902 *ptr = 0;
902 903
904 #ifdef emacs
903 refill_memory_reserve (); 905 refill_memory_reserve ();
906 #endif
904 } 907 }
905 908
906 /* Given a pointer at address PTR to relocatable data, resize it to SIZE. 909 /* Given a pointer at address PTR to relocatable data, resize it to SIZE.
907 Do this by shifting all blocks above this one up in memory, unless 910 Do this by shifting all blocks above this one up in memory, unless
908 SIZE is less than or equal to the current bloc size, in which case 911 SIZE is less than or equal to the current bloc size, in which case