comparison src/alloc.c @ 1726:a8d8f419b459

[xemacs-hg @ 2003-09-30 15:26:34 by james] Add type information to xfree to avoid alias creation.
author james
date Tue, 30 Sep 2003 15:27:01 +0000
parents a72f7bf813c9
children 68ed93de81b7
comparison
equal deleted inserted replaced
1725:7ff8f4d70aec 1726:a8d8f419b459
250 { 250 {
251 if (breathing_space) 251 if (breathing_space)
252 { 252 {
253 void *tmp = breathing_space; 253 void *tmp = breathing_space;
254 breathing_space = 0; 254 breathing_space = 0;
255 xfree (tmp); 255 xfree (tmp, void *);
256 } 256 }
257 } 257 }
258 258
259 /* malloc calls this if it finds we are near exhausting storage */ 259 /* malloc calls this if it finds we are near exhausting storage */
260 void 260 void
381 set_alloc_mins_and_maxes (block, size); 381 set_alloc_mins_and_maxes (block, size);
382 return block; 382 return block;
383 } 383 }
384 384
385 void 385 void
386 #ifdef ERROR_CHECK_MALLOC
387 xfree_1 (void *block) 386 xfree_1 (void *block)
388 #else
389 xfree (void *block)
390 #endif
391 { 387 {
392 #ifdef ERROR_CHECK_MALLOC 388 #ifdef ERROR_CHECK_MALLOC
393 /* Unbelievably, calling free() on 0xDEADBEEF doesn't cause an 389 /* Unbelievably, calling free() on 0xDEADBEEF doesn't cause an
394 error until much later on for many system mallocs, such as 390 error until much later on for many system mallocs, such as
395 the one that comes with Solaris 2.3. FMH!! */ 391 the one that comes with Solaris 2.3. FMH!! */
2263 memcpy (new_data, old_data, pos); 2259 memcpy (new_data, old_data, pos);
2264 memcpy (new_data + pos + delta, old_data + pos, 2260 memcpy (new_data + pos + delta, old_data + pos,
2265 XSTRING_LENGTH (s) + 1 - pos); 2261 XSTRING_LENGTH (s) + 1 - pos);
2266 } 2262 }
2267 XSET_STRING_DATA (s, new_data); 2263 XSET_STRING_DATA (s, new_data);
2268 xfree (old_data); 2264 xfree (old_data, Ibyte *);
2269 } 2265 }
2270 } 2266 }
2271 else /* old string is small */ 2267 else /* old string is small */
2272 { 2268 {
2273 if (oldfullsize == newfullsize) 2269 if (oldfullsize == newfullsize)
3596 { 3592 {
3597 struct lcrecord_header *next = header->next; 3593 struct lcrecord_header *next = header->next;
3598 *prev = next; 3594 *prev = next;
3599 tick_lcrecord_stats (h, 1); 3595 tick_lcrecord_stats (h, 1);
3600 /* used to call finalizer right here. */ 3596 /* used to call finalizer right here. */
3601 xfree (header); 3597 xfree (header, struct lcrecord_header *);
3602 header = next; 3598 header = next;
3603 } 3599 }
3604 } 3600 }
3605 *used = num_used; 3601 *used = num_used;
3606 /* *total = total_size; */ 3602 /* *total = total_size; */
3720 current_##typename##_block_index \ 3716 current_##typename##_block_index \
3721 = countof (current_##typename##_block->block); \ 3717 = countof (current_##typename##_block->block); \
3722 SFTB_current = SFTB_current->prev; \ 3718 SFTB_current = SFTB_current->prev; \
3723 { \ 3719 { \
3724 *SFTB_prev = SFTB_current; \ 3720 *SFTB_prev = SFTB_current; \
3725 xfree (SFTB_victim_block); \ 3721 xfree (SFTB_victim_block, struct typename##_block *); \
3726 /* Restore free list to what it was before victim was swept */ \ 3722 /* Restore free list to what it was before victim was swept */ \
3727 typename##_free_list = SFTB_old_free_list; \ 3723 typename##_free_list = SFTB_old_free_list; \
3728 num_free -= SFTB_limit; \ 3724 num_free -= SFTB_limit; \
3729 } \ 3725 } \
3730 } \ 3726 } \
3814 static void 3810 static void
3815 sweep_compiled_functions (void) 3811 sweep_compiled_functions (void)
3816 { 3812 {
3817 #define UNMARK_compiled_function(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader)) 3813 #define UNMARK_compiled_function(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader))
3818 #define ADDITIONAL_FREE_compiled_function(ptr) \ 3814 #define ADDITIONAL_FREE_compiled_function(ptr) \
3819 if (ptr->args_in_array) xfree (ptr->args) 3815 if (ptr->args_in_array) xfree (ptr->args, Lisp_Object *)
3820 3816
3821 SWEEP_FIXED_TYPE_BLOCK (compiled_function, Lisp_Compiled_Function); 3817 SWEEP_FIXED_TYPE_BLOCK (compiled_function, Lisp_Compiled_Function);
3822 } 3818 }
3823 3819
3824 static void 3820 static void
4152 struct string_chars_block *victim; 4148 struct string_chars_block *victim;
4153 4149
4154 for (victim = to_sb->next; victim; ) 4150 for (victim = to_sb->next; victim; )
4155 { 4151 {
4156 struct string_chars_block *next = victim->next; 4152 struct string_chars_block *next = victim->next;
4157 xfree (victim); 4153 xfree (victim, struct string_chars_block *);
4158 victim = next; 4154 victim = next;
4159 } 4155 }
4160 4156
4161 current_string_chars_block = to_sb; 4157 current_string_chars_block = to_sb;
4162 current_string_chars_block->pos = to_pos; 4158 current_string_chars_block->pos = to_pos;
4209 debug_string_purity_print (wrap_string (p)); \ 4205 debug_string_purity_print (wrap_string (p)); \
4210 } while (0) 4206 } while (0)
4211 #define ADDITIONAL_FREE_string(ptr) do { \ 4207 #define ADDITIONAL_FREE_string(ptr) do { \
4212 Bytecount size = ptr->size_; \ 4208 Bytecount size = ptr->size_; \
4213 if (BIG_STRING_SIZE_P (size)) \ 4209 if (BIG_STRING_SIZE_P (size)) \
4214 xfree (ptr->data_); \ 4210 xfree (ptr->data_, Ibyte *); \
4215 } while (0) 4211 } while (0)
4216 4212
4217 SWEEP_FIXED_TYPE_BLOCK_1 (string, Lisp_String, u.lheader); 4213 SWEEP_FIXED_TYPE_BLOCK_1 (string, Lisp_String, u.lheader);
4218 4214
4219 gc_count_num_short_string_in_use = num_small_used; 4215 gc_count_num_short_string_in_use = num_small_used;