diff options
Diffstat (limited to 'src/ralloc.c')
| -rw-r--r-- | src/ralloc.c | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/src/ralloc.c b/src/ralloc.c index dd68e7c8afc..0a2b156e393 100644 --- a/src/ralloc.c +++ b/src/ralloc.c | |||
| @@ -37,11 +37,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 37 | typedef POINTER_TYPE *POINTER; | 37 | typedef POINTER_TYPE *POINTER; |
| 38 | typedef size_t SIZE; | 38 | typedef size_t SIZE; |
| 39 | 39 | ||
| 40 | /* Declared in dispnew.c, this version doesn't screw up if regions | ||
| 41 | overlap. */ | ||
| 42 | |||
| 43 | extern void safe_bcopy (const char *, char *, int); | ||
| 44 | |||
| 45 | #ifdef DOUG_LEA_MALLOC | 40 | #ifdef DOUG_LEA_MALLOC |
| 46 | #define M_TOP_PAD -2 | 41 | #define M_TOP_PAD -2 |
| 47 | extern int mallopt (int, int); | 42 | extern int mallopt (int, int); |
| @@ -61,9 +56,6 @@ typedef void *POINTER; | |||
| 61 | #include <unistd.h> | 56 | #include <unistd.h> |
| 62 | #include <malloc.h> | 57 | #include <malloc.h> |
| 63 | 58 | ||
| 64 | #define safe_bcopy(x, y, z) memmove (y, x, z) | ||
| 65 | #define bzero(x, len) memset (x, 0, len) | ||
| 66 | |||
| 67 | #endif /* not emacs */ | 59 | #endif /* not emacs */ |
| 68 | 60 | ||
| 69 | 61 | ||
| @@ -676,7 +668,7 @@ resize_bloc (bloc_ptr bloc, SIZE size) | |||
| 676 | } | 668 | } |
| 677 | else | 669 | else |
| 678 | { | 670 | { |
| 679 | safe_bcopy (b->data, b->new_data, b->size); | 671 | memmove (b->new_data, b->data, b->size); |
| 680 | *b->variable = b->data = b->new_data; | 672 | *b->variable = b->data = b->new_data; |
| 681 | } | 673 | } |
| 682 | } | 674 | } |
| @@ -687,8 +679,8 @@ resize_bloc (bloc_ptr bloc, SIZE size) | |||
| 687 | } | 679 | } |
| 688 | else | 680 | else |
| 689 | { | 681 | { |
| 690 | safe_bcopy (bloc->data, bloc->new_data, old_size); | 682 | memmove (bloc->new_data, bloc->data, old_size); |
| 691 | bzero ((char *) bloc->new_data + old_size, size - old_size); | 683 | memset (bloc->new_data + old_size, 0, size - old_size); |
| 692 | *bloc->variable = bloc->data = bloc->new_data; | 684 | *bloc->variable = bloc->data = bloc->new_data; |
| 693 | } | 685 | } |
| 694 | } | 686 | } |
| @@ -703,7 +695,7 @@ resize_bloc (bloc_ptr bloc, SIZE size) | |||
| 703 | } | 695 | } |
| 704 | else | 696 | else |
| 705 | { | 697 | { |
| 706 | safe_bcopy (b->data, b->new_data, b->size); | 698 | memmove (b->new_data, b->data, b->size); |
| 707 | *b->variable = b->data = b->new_data; | 699 | *b->variable = b->data = b->new_data; |
| 708 | } | 700 | } |
| 709 | } | 701 | } |
| @@ -856,7 +848,7 @@ r_alloc_sbrk (long int size) | |||
| 856 | header. */ | 848 | header. */ |
| 857 | for (b = last_bloc; b != NIL_BLOC; b = b->prev) | 849 | for (b = last_bloc; b != NIL_BLOC; b = b->prev) |
| 858 | { | 850 | { |
| 859 | safe_bcopy (b->data, b->new_data, b->size); | 851 | memmove (b->new_data, b->data, b->size); |
| 860 | *b->variable = b->data = b->new_data; | 852 | *b->variable = b->data = b->new_data; |
| 861 | } | 853 | } |
| 862 | 854 | ||
| @@ -883,7 +875,7 @@ r_alloc_sbrk (long int size) | |||
| 883 | last_heap = first_heap; | 875 | last_heap = first_heap; |
| 884 | } | 876 | } |
| 885 | 877 | ||
| 886 | bzero (address, size); | 878 | memset (address, 0, size); |
| 887 | } | 879 | } |
| 888 | else /* size < 0 */ | 880 | else /* size < 0 */ |
| 889 | { | 881 | { |
| @@ -902,7 +894,7 @@ r_alloc_sbrk (long int size) | |||
| 902 | 894 | ||
| 903 | for (b = first_bloc; b != NIL_BLOC; b = b->next) | 895 | for (b = first_bloc; b != NIL_BLOC; b = b->next) |
| 904 | { | 896 | { |
| 905 | safe_bcopy (b->data, b->new_data, b->size); | 897 | memmove (b->new_data, b->data, b->size); |
| 906 | *b->variable = b->data = b->new_data; | 898 | *b->variable = b->data = b->new_data; |
| 907 | } | 899 | } |
| 908 | } | 900 | } |
| @@ -1082,7 +1074,7 @@ r_alloc_thaw (void) | |||
| 1082 | abort (); | 1074 | abort (); |
| 1083 | 1075 | ||
| 1084 | /* This frees all unused blocs. It is not too inefficient, as the resize | 1076 | /* This frees all unused blocs. It is not too inefficient, as the resize |
| 1085 | and bcopy is done only once. Afterwards, all unreferenced blocs are | 1077 | and memcpy is done only once. Afterwards, all unreferenced blocs are |
| 1086 | already shrunk to zero size. */ | 1078 | already shrunk to zero size. */ |
| 1087 | if (!r_alloc_freeze_level) | 1079 | if (!r_alloc_freeze_level) |
| 1088 | { | 1080 | { |
| @@ -1292,8 +1284,8 @@ r_alloc_init (void) | |||
| 1292 | even though it is after the sbrk value. */ | 1284 | even though it is after the sbrk value. */ |
| 1293 | /* Doubly true, with the additional call that explicitly adds the | 1285 | /* Doubly true, with the additional call that explicitly adds the |
| 1294 | rest of that page to the address space. */ | 1286 | rest of that page to the address space. */ |
| 1295 | bzero (first_heap->start, | 1287 | memset (first_heap->start, 0, |
| 1296 | (char *) first_heap->end - (char *) first_heap->start); | 1288 | (char *) first_heap->end - (char *) first_heap->start); |
| 1297 | virtual_break_value = break_value = first_heap->bloc_start = first_heap->end; | 1289 | virtual_break_value = break_value = first_heap->bloc_start = first_heap->end; |
| 1298 | #endif | 1290 | #endif |
| 1299 | 1291 | ||