comparison src/free-hook.c @ 272:c5d627a313b1 r21-0b34

Import from CVS: tag r21-0b34
author cvs
date Mon, 13 Aug 2007 10:28:48 +0200
parents b2472a1930f2
children fbbf69b4e8a7
comparison
equal deleted inserted replaced
271:c7b7086b0a39 272:c5d627a313b1
218 #ifdef UNMAPPED_FREE 218 #ifdef UNMAPPED_FREE
219 unsigned long rounded_up_size; 219 unsigned long rounded_up_size;
220 #endif 220 #endif
221 221
222 EMACS_INT present = (EMACS_INT) gethash (ptr, pointer_table, 222 EMACS_INT present = (EMACS_INT) gethash (ptr, pointer_table,
223 (void **) &size); 223 (CONST void **) &size);
224 224
225 if (!present) 225 if (!present)
226 { 226 {
227 /* This can only happen if you try to free something that didn't 227 /* This can only happen if you try to free something that didn't
228 come from malloc */ 228 come from malloc */
229 #if !defined(__linux__) 229 #if !defined(__linux__)
230 /* I originally wrote: "There's really no need to drop core." 230 /* I originally wrote: "There's really no need to drop core."
231 I have seen the error of my ways. -slb */ 231 I have seen the error of my ways. -slb */
232 if (strict_free_check) 232 if (strict_free_check)
233 { 233 abort ();
234 abort ();
235 }
236 #endif 234 #endif
237 printf("Freeing unmalloc'ed memory at %p\n", ptr); 235 printf("Freeing unmalloc'ed memory at %p\n", ptr);
238 __free_hook = check_free; 236 __free_hook = check_free;
239 __malloc_hook = check_malloc; 237 __malloc_hook = check_malloc;
240 goto end; 238 goto end;
244 { 242 {
245 /* This happens when you free twice */ 243 /* This happens when you free twice */
246 #if !defined(__linux__) 244 #if !defined(__linux__)
247 /* See above comment. */ 245 /* See above comment. */
248 if (strict_free_check) 246 if (strict_free_check)
249 { 247 abort ();
250 abort ();
251 }
252 #endif 248 #endif
253 printf("Freeing %p twice\n", ptr); 249 printf("Freeing %p twice\n", ptr);
254 __free_hook = check_free; 250 __free_hook = check_free;
255 __malloc_hook = check_malloc; 251 __malloc_hook = check_malloc;
256 goto end; 252 goto end;
351 EMACS_INT present; 347 EMACS_INT present;
352 unsigned long old_size; 348 unsigned long old_size;
353 void *result = malloc (size); 349 void *result = malloc (size);
354 350
355 if (!ptr) return result; 351 if (!ptr) return result;
356 present = (EMACS_INT) gethash (ptr, pointer_table, (void **) &old_size); 352 present = (EMACS_INT) gethash (ptr, pointer_table, (CONST void **) &old_size);
357 if (!present) 353 if (!present)
358 { 354 {
359 /* This can only happen by reallocing a pointer that didn't 355 /* This can only happen by reallocing a pointer that didn't
360 come from malloc. */ 356 come from malloc. */
361 #if !defined(__linux__) 357 #if !defined(__linux__)