summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormillert <>1997-07-02 16:26:27 +0000
committermillert <>1997-07-02 16:26:27 +0000
commiteb1df34c5066d83120f925424d530de354d33f53 (patch)
treea4ef0da7b5d3e92451ce2aee8fe8444abb018547 /src
parent0bf58fe735efbe7f2f089eca10449eeaabac24c6 (diff)
downloadopenbsd-eb1df34c5066d83120f925424d530de354d33f53.tar.gz
openbsd-eb1df34c5066d83120f925424d530de354d33f53.tar.bz2
openbsd-eb1df34c5066d83120f925424d530de354d33f53.zip
Use MALLOC_EXTRA_SANITY consistently (EXTRA_SANITY was used in many places)
sizeof *pt -> sizeof *px (point to same type of struct but looked wrong).
Diffstat (limited to 'src')
-rw-r--r--src/lib/libc/stdlib/malloc.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c
index e8c352ca43..9d9c69ad00 100644
--- a/src/lib/libc/stdlib/malloc.c
+++ b/src/lib/libc/stdlib/malloc.c
@@ -8,13 +8,13 @@
8 */ 8 */
9 9
10#if defined(LIBC_SCCS) && !defined(lint) 10#if defined(LIBC_SCCS) && !defined(lint)
11static char rcsid[] = "$OpenBSD: malloc.c,v 1.26 1997/05/31 08:55:06 tholo Exp $"; 11static char rcsid[] = "$OpenBSD: malloc.c,v 1.27 1997/07/02 16:26:27 millert Exp $";
12#endif /* LIBC_SCCS and not lint */ 12#endif /* LIBC_SCCS and not lint */
13 13
14/* 14/*
15 * Defining EXTRA_SANITY will enable extra checks which are related 15 * Defining MALLOC_EXTRA_SANITY will enable extra checks which are
16 * to internal conditions and consistency in malloc.c. This has a 16 * related to internal conditions and consistency in malloc.c. This has
17 * noticeable runtime performance hit, and generally will not do you 17 * a noticeable runtime performance hit, and generally will not do you
18 * any good unless you fiddle with the internals of malloc or want 18 * any good unless you fiddle with the internals of malloc or want
19 * to catch random pointer corruption as early as possible. 19 * to catch random pointer corruption as early as possible.
20 */ 20 */
@@ -278,6 +278,7 @@ static int extend_pgdir(u_long index);
278static void *imalloc(size_t size); 278static void *imalloc(size_t size);
279static void ifree(void *ptr); 279static void ifree(void *ptr);
280static void *irealloc(void *ptr, size_t size); 280static void *irealloc(void *ptr, size_t size);
281static void *malloc_bytes(size_t size);
281 282
282#ifdef MALLOC_STATS 283#ifdef MALLOC_STATS
283void 284void
@@ -400,9 +401,9 @@ map_pages(pages)
400 tail = result + (pages << malloc_pageshift); 401 tail = result + (pages << malloc_pageshift);
401 402
402 if (brk(tail)) { 403 if (brk(tail)) {
403#ifdef EXTRA_SANITY 404#ifdef MALLOC_EXTRA_SANITY
404 wrterror("(ES): map_pages fails\n"); 405 wrterror("(ES): map_pages fails\n");
405#endif /* EXTRA_SANITY */ 406#endif /* MALLOC_EXTRA_SANITY */
406 return 0; 407 return 0;
407 } 408 }
408 409
@@ -482,9 +483,9 @@ malloc_init ()
482 483
483 INIT_MMAP(); 484 INIT_MMAP();
484 485
485#ifdef EXTRA_SANITY 486#ifdef MALLOC_EXTRA_SANITY
486 malloc_junk = 1; 487 malloc_junk = 1;
487#endif /* EXTRA_SANITY */ 488#endif /* MALLOC_EXTRA_SANITY */
488 489
489 for (i = 0; i < 3; i++) { 490 for (i = 0; i < 3; i++) {
490 if (i == 0) { 491 if (i == 0) {
@@ -604,7 +605,7 @@ malloc_pages(size)
604 /* Look for free pages before asking for more */ 605 /* Look for free pages before asking for more */
605 for(pf = free_list.next; pf; pf = pf->next) { 606 for(pf = free_list.next; pf; pf = pf->next) {
606 607
607#ifdef EXTRA_SANITY 608#ifdef MALLOC_EXTRA_SANITY
608 if (pf->size & malloc_pagemask) 609 if (pf->size & malloc_pagemask)
609 wrterror("(ES): junk length entry on free_list\n"); 610 wrterror("(ES): junk length entry on free_list\n");
610 if (!pf->size) 611 if (!pf->size)
@@ -619,7 +620,7 @@ malloc_pages(size)
619 wrterror("(ES): non-free first page on free-list\n"); 620 wrterror("(ES): non-free first page on free-list\n");
620 if (page_dir[ptr2index(pf->end)-1] != MALLOC_FREE) 621 if (page_dir[ptr2index(pf->end)-1] != MALLOC_FREE)
621 wrterror("(ES): non-free last page on free-list\n"); 622 wrterror("(ES): non-free last page on free-list\n");
622#endif /* EXTRA_SANITY */ 623#endif /* MALLOC_EXTRA_SANITY */
623 624
624 if (pf->size < size) 625 if (pf->size < size)
625 continue; 626 continue;
@@ -639,10 +640,10 @@ malloc_pages(size)
639 break; 640 break;
640 } 641 }
641 642
642#ifdef EXTRA_SANITY 643#ifdef MALLOC_EXTRA_SANITY
643 if (p && page_dir[ptr2index(p)] != MALLOC_FREE) 644 if (p && page_dir[ptr2index(p)] != MALLOC_FREE)
644 wrterror("(ES): allocated non-free page on free-list\n"); 645 wrterror("(ES): allocated non-free page on free-list\n");
645#endif /* EXTRA_SANITY */ 646#endif /* MALLOC_EXTRA_SANITY */
646 647
647 size >>= malloc_pageshift; 648 size >>= malloc_pageshift;
648 649
@@ -977,7 +978,7 @@ free_pages(ptr, index, info)
977 978
978 /* add to free-list */ 979 /* add to free-list */
979 if (!px) 980 if (!px)
980 px = imalloc(sizeof *pt); /* This cannot fail... */ 981 px = imalloc(sizeof *px); /* This cannot fail... */
981 px->page = ptr; 982 px->page = ptr;
982 px->end = tail; 983 px->end = tail;
983 px->size = l; 984 px->size = l;
@@ -1118,10 +1119,10 @@ free_bytes(ptr, index, info)
1118 /* Find & remove this page in the queue */ 1119 /* Find & remove this page in the queue */
1119 while (*mp != info) { 1120 while (*mp != info) {
1120 mp = &((*mp)->next); 1121 mp = &((*mp)->next);
1121#ifdef EXTRA_SANITY 1122#ifdef MALLOC_EXTRA_SANITY
1122 if (!*mp) 1123 if (!*mp)
1123 wrterror("(ES): Not on queue\n"); 1124 wrterror("(ES): Not on queue\n");
1124#endif /* EXTRA_SANITY */ 1125#endif /* MALLOC_EXTRA_SANITY */
1125 } 1126 }
1126 *mp = info->next; 1127 *mp = info->next;
1127 1128