comparison src/alloc.c @ 59083:4295cf593352

Update comment for check_depth.
author Jan Dj?rv <jan.h.d@swipnet.se>
date Sat, 25 Dec 2004 10:31:36 +0000
parents f487226310e0
children 9c620c1aa7fa 223c12363c0c 95879cc1ed20
comparison
equal deleted inserted replaced
59082:f487226310e0 59083:4295cf593352
599 ((unsigned)(ptr[-2]) << 8) | \ 599 ((unsigned)(ptr[-2]) << 8) | \
600 ((unsigned)(ptr[-3]) << 16) | \ 600 ((unsigned)(ptr[-3]) << 16) | \
601 ((unsigned)(ptr[-4]) << 24)) 601 ((unsigned)(ptr[-4]) << 24))
602 602
603 603
604 /* The call depth in overrun_check functions. Realloc may call both malloc 604 /* The call depth in overrun_check functions. For example, this might happen:
605 and free. If realloc calls malloc, this may happen: 605 xmalloc()
606 overrun_check_realloc() 606 overrun_check_malloc()
607 -> malloc -> (via hook)_-> emacs_blocked_malloc 607 -> malloc -> (via hook)_-> emacs_blocked_malloc
608 -> overrun_check_malloc 608 -> overrun_check_malloc
609 call malloc (hooks are NULL, so real malloc is called). 609 call malloc (hooks are NULL, so real malloc is called).
610 malloc returns 10000. 610 malloc returns 10000.
611 add overhead, return 10016. 611 add overhead, return 10016.
612 <- (back in overrun_check_realloc) 612 <- (back in overrun_check_malloc)
613 add overhead again, return 10032 613 add overhead again, return 10032
614 xmalloc returns 10032.
614 615
615 (time passes). 616 (time passes).
616 617
617 overrun_check_free(10032) 618 xfree(10032)
618 decrease overhed 619 overrun_check_free(10032)
619 free(10016) <- crash, because 10000 is the original pointer. */ 620 decrease overhed
621 free(10016) <- crash, because 10000 is the original pointer. */
620 622
621 static int check_depth; 623 static int check_depth;
622 624
623 /* Like malloc, but wraps allocated block with header and trailer. */ 625 /* Like malloc, but wraps allocated block with header and trailer. */
624 626