summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libc/stdlib/malloc.c103
1 files changed, 60 insertions, 43 deletions
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c
index e1e1831a94..4a38c53bbd 100644
--- a/src/lib/libc/stdlib/malloc.c
+++ b/src/lib/libc/stdlib/malloc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: malloc.c,v 1.80 2006/02/14 11:14:11 espie Exp $ */ 1/* $OpenBSD: malloc.c,v 1.81 2006/04/18 18:26:13 otto Exp $ */
2 2
3/* 3/*
4 * ---------------------------------------------------------------------------- 4 * ----------------------------------------------------------------------------
@@ -114,7 +114,7 @@ struct pgfree {
114#define MALLOC_MAGIC ((struct pginfo*) 4) 114#define MALLOC_MAGIC ((struct pginfo*) 4)
115 115
116#ifndef malloc_minsize 116#ifndef malloc_minsize
117#define malloc_minsize 16U 117#define malloc_minsize 16UL
118#endif 118#endif
119 119
120#if !defined(malloc_pagesize) 120#if !defined(malloc_pagesize)
@@ -189,8 +189,8 @@ static int malloc_realloc;
189static int malloc_freeprot; 189static int malloc_freeprot;
190 190
191/* use guard pages after allocations? */ 191/* use guard pages after allocations? */
192static int malloc_guard = 0; 192static size_t malloc_guard = 0;
193static int malloc_guarded; 193static size_t malloc_guarded;
194/* align pointers to end of page? */ 194/* align pointers to end of page? */
195static int malloc_ptrguard; 195static int malloc_ptrguard;
196 196
@@ -231,7 +231,7 @@ static int malloc_active;
231static size_t malloc_used; 231static size_t malloc_used;
232 232
233/* My last break. */ 233/* My last break. */
234static void *malloc_brk; 234static caddr_t malloc_brk;
235 235
236/* One location cache for free-list holders. */ 236/* One location cache for free-list holders. */
237static struct pgfree *px; 237static struct pgfree *px;
@@ -310,14 +310,14 @@ malloc_dump(int fd)
310 struct pginfo **pd; 310 struct pginfo **pd;
311 struct pgfree *pf; 311 struct pgfree *pf;
312 struct pdinfo *pi; 312 struct pdinfo *pi;
313 int j; 313 u_long j;
314 314
315 pd = page_dir; 315 pd = page_dir;
316 pi = (struct pdinfo *) ((caddr_t) pd + pdi_off); 316 pi = (struct pdinfo *) ((caddr_t) pd + pdi_off);
317 317
318 /* print out all the pages */ 318 /* print out all the pages */
319 for (j = 0; j <= last_index;) { 319 for (j = 0; j <= last_index;) {
320 snprintf(buf, sizeof buf, "%08lx %5d ", j << malloc_pageshift, j); 320 snprintf(buf, sizeof buf, "%08lx %5lu ", j << malloc_pageshift, j);
321 write(fd, buf, strlen(buf)); 321 write(fd, buf, strlen(buf));
322 if (pd[PI_OFF(j)] == MALLOC_NOT_MINE) { 322 if (pd[PI_OFF(j)] == MALLOC_NOT_MINE) {
323 for (j++; j <= last_index && pd[PI_OFF(j)] == MALLOC_NOT_MINE;) { 323 for (j++; j <= last_index && pd[PI_OFF(j)] == MALLOC_NOT_MINE;) {
@@ -330,7 +330,7 @@ malloc_dump(int fd)
330 } 330 }
331 } 331 }
332 j--; 332 j--;
333 snprintf(buf, sizeof buf, ".. %5d not mine\n", j); 333 snprintf(buf, sizeof buf, ".. %5lu not mine\n", j);
334 write(fd, buf, strlen(buf)); 334 write(fd, buf, strlen(buf));
335 } else if (pd[PI_OFF(j)] == MALLOC_FREE) { 335 } else if (pd[PI_OFF(j)] == MALLOC_FREE) {
336 for (j++; j <= last_index && pd[PI_OFF(j)] == MALLOC_FREE;) { 336 for (j++; j <= last_index && pd[PI_OFF(j)] == MALLOC_FREE;) {
@@ -343,7 +343,7 @@ malloc_dump(int fd)
343 } 343 }
344 } 344 }
345 j--; 345 j--;
346 snprintf(buf, sizeof buf, ".. %5d free\n", j); 346 snprintf(buf, sizeof buf, ".. %5lu free\n", j);
347 write(fd, buf, strlen(buf)); 347 write(fd, buf, strlen(buf));
348 } else if (pd[PI_OFF(j)] == MALLOC_FIRST) { 348 } else if (pd[PI_OFF(j)] == MALLOC_FIRST) {
349 for (j++; j <= last_index && pd[PI_OFF(j)] == MALLOC_FOLLOW;) { 349 for (j++; j <= last_index && pd[PI_OFF(j)] == MALLOC_FOLLOW;) {
@@ -356,7 +356,7 @@ malloc_dump(int fd)
356 } 356 }
357 } 357 }
358 j--; 358 j--;
359 snprintf(buf, sizeof buf, ".. %5d in use\n", j); 359 snprintf(buf, sizeof buf, ".. %5lu in use\n", j);
360 write(fd, buf, strlen(buf)); 360 write(fd, buf, strlen(buf));
361 } else if (pd[PI_OFF(j)] < MALLOC_MAGIC) { 361 } else if (pd[PI_OFF(j)] < MALLOC_MAGIC) {
362 snprintf(buf, sizeof buf, "(%p)\n", pd[PI_OFF(j)]); 362 snprintf(buf, sizeof buf, "(%p)\n", pd[PI_OFF(j)]);
@@ -378,7 +378,7 @@ malloc_dump(int fd)
378 378
379 for (pf = free_list.next; pf; pf = pf->next) { 379 for (pf = free_list.next; pf; pf = pf->next) {
380 snprintf(buf, sizeof buf, "Free: @%p [%p...%p[ %ld ->%p <-%p\n", 380 snprintf(buf, sizeof buf, "Free: @%p [%p...%p[ %ld ->%p <-%p\n",
381 pf, pf->page, pf->page + pf->size, 381 pf, pf->page, (char *)pf->page + pf->size,
382 pf->size, pf->prev, pf->next); 382 pf->size, pf->prev, pf->next);
383 write(fd, buf, strlen(buf)); 383 write(fd, buf, strlen(buf));
384 if (pf == pf->next) { 384 if (pf == pf->next) {
@@ -389,13 +389,13 @@ malloc_dump(int fd)
389 } 389 }
390 390
391 /* print out various info */ 391 /* print out various info */
392 snprintf(buf, sizeof buf, "Minsize\t%d\n", malloc_minsize); 392 snprintf(buf, sizeof buf, "Minsize\t%lu\n", malloc_minsize);
393 write(fd, buf, strlen(buf)); 393 write(fd, buf, strlen(buf));
394 snprintf(buf, sizeof buf, "Maxsize\t%d\n", malloc_maxsize); 394 snprintf(buf, sizeof buf, "Maxsize\t%lu\n", malloc_maxsize);
395 write(fd, buf, strlen(buf)); 395 write(fd, buf, strlen(buf));
396 snprintf(buf, sizeof buf, "Pagesize\t%lu\n", (u_long) malloc_pagesize); 396 snprintf(buf, sizeof buf, "Pagesize\t%lu\n", malloc_pagesize);
397 write(fd, buf, strlen(buf)); 397 write(fd, buf, strlen(buf));
398 snprintf(buf, sizeof buf, "Pageshift\t%d\n", malloc_pageshift); 398 snprintf(buf, sizeof buf, "Pageshift\t%u\n", malloc_pageshift);
399 write(fd, buf, strlen(buf)); 399 write(fd, buf, strlen(buf));
400 snprintf(buf, sizeof buf, "In use\t%lu\n", (u_long) malloc_used); 400 snprintf(buf, sizeof buf, "In use\t%lu\n", (u_long) malloc_used);
401 write(fd, buf, strlen(buf)); 401 write(fd, buf, strlen(buf));
@@ -485,7 +485,7 @@ map_pages(size_t pages)
485 struct pdinfo *pi, *spi; 485 struct pdinfo *pi, *spi;
486 struct pginfo **pd; 486 struct pginfo **pd;
487 u_long idx, pidx, lidx; 487 u_long idx, pidx, lidx;
488 void *result, *tail; 488 caddr_t result, tail;
489 u_long index, lindex; 489 u_long index, lindex;
490 490
491 pages <<= malloc_pageshift; 491 pages <<= malloc_pageshift;
@@ -517,7 +517,7 @@ map_pages(size_t pages)
517 if (pi == NULL || PD_IDX(pi->dirnum) != idx) { 517 if (pi == NULL || PD_IDX(pi->dirnum) != idx) {
518 if ((pd = MMAP(malloc_pagesize)) == MAP_FAILED) { 518 if ((pd = MMAP(malloc_pagesize)) == MAP_FAILED) {
519 errno = ENOMEM; /* XXX */ 519 errno = ENOMEM; /* XXX */
520 munmap(result, tail - result); 520 munmap(result, (size_t)(tail - result));
521#ifdef MALLOC_EXTRA_SANITY 521#ifdef MALLOC_EXTRA_SANITY
522 wrtwarning("(ES): map_pages fails"); 522 wrtwarning("(ES): map_pages fails");
523#endif /* MALLOC_EXTRA_SANITY */ 523#endif /* MALLOC_EXTRA_SANITY */
@@ -528,7 +528,8 @@ map_pages(size_t pages)
528 pi->base = pd; 528 pi->base = pd;
529 pi->prev = spi; 529 pi->prev = spi;
530 pi->next = spi->next; 530 pi->next = spi->next;
531 pi->dirnum = idx * (malloc_pagesize / sizeof(struct pginfo *)); 531 pi->dirnum = idx * (malloc_pagesize /
532 sizeof(struct pginfo *));
532 533
533 if (spi->next != NULL) 534 if (spi->next != NULL)
534 spi->next->prev = pi; 535 spi->next->prev = pi;
@@ -538,7 +539,8 @@ map_pages(size_t pages)
538 pi->dirnum += pdi_mod; 539 pi->dirnum += pdi_mod;
539 } else if (idx == pidx) { 540 } else if (idx == pidx) {
540 if (pidx == lidx) { 541 if (pidx == lidx) {
541 pi->dirnum += (tail - result) >> malloc_pageshift; 542 pi->dirnum += (u_long)(tail - result) >>
543 malloc_pageshift;
542 } else { 544 } else {
543 pi->dirnum += pdi_mod - PI_OFF(index); 545 pi->dirnum += pdi_mod - PI_OFF(index);
544 } 546 }
@@ -927,9 +929,12 @@ malloc_make_chunks(int bits)
927{ 929{
928 struct pginfo *bp, **pd; 930 struct pginfo *bp, **pd;
929 struct pdinfo *pi; 931 struct pdinfo *pi;
932#ifdef MALLOC_EXTRA_SANITY
930 u_long pidx; 933 u_long pidx;
934#endif /* MALLOC_EXTRA_SANITY */
931 void *pp; 935 void *pp;
932 int i, k, l; 936 long i, k;
937 size_t l;
933 938
934 /* Allocate a new bucket */ 939 /* Allocate a new bucket */
935 pp = malloc_pages((size_t) malloc_pagesize); 940 pp = malloc_pages((size_t) malloc_pagesize);
@@ -987,26 +992,27 @@ malloc_make_chunks(int bits)
987 i = 0; 992 i = 0;
988 993
989 /* Do a bunch at a time */ 994 /* Do a bunch at a time */
990 for (; k - i >= MALLOC_BITS; i += MALLOC_BITS) 995 for (; (k - i) >= MALLOC_BITS; i += MALLOC_BITS)
991 bp->bits[i / MALLOC_BITS] = ~0UL; 996 bp->bits[i / MALLOC_BITS] = ~0UL;
992 997
993 for (; i < k; i++) 998 for (; i < k; i++)
994 bp->bits[i / MALLOC_BITS] |= 1UL << (i % MALLOC_BITS); 999 bp->bits[i / MALLOC_BITS] |= 1UL << (i % MALLOC_BITS);
995 1000
1001 k = (long)l;
996 if (bp == bp->page) { 1002 if (bp == bp->page) {
997 /* Mark the ones we stole for ourselves */ 1003 /* Mark the ones we stole for ourselves */
998 for (i = 0; l > 0; i++) { 1004 for (i = 0; k > 0; i++) {
999 bp->bits[i / MALLOC_BITS] &= ~(1UL << (i % MALLOC_BITS)); 1005 bp->bits[i / MALLOC_BITS] &= ~(1UL << (i % MALLOC_BITS));
1000 bp->free--; 1006 bp->free--;
1001 bp->total--; 1007 bp->total--;
1002 l -= (1 << bits); 1008 k -= (1 << bits);
1003 } 1009 }
1004 } 1010 }
1005 /* MALLOC_LOCK */ 1011 /* MALLOC_LOCK */
1006 1012
1007 pidx = PI_IDX(ptr2index(pp));
1008 pdir_lookup(ptr2index(pp), &pi); 1013 pdir_lookup(ptr2index(pp), &pi);
1009#ifdef MALLOC_EXTRA_SANITY 1014#ifdef MALLOC_EXTRA_SANITY
1015 pidx = PI_IDX(ptr2index(pp));
1010 if (pi == NULL || PD_IDX(pi->dirnum) != pidx) { 1016 if (pi == NULL || PD_IDX(pi->dirnum) != pidx) {
1011 wrterror("(ES): mapped pages not found in directory"); 1017 wrterror("(ES): mapped pages not found in directory");
1012 errno = EFAULT; 1018 errno = EFAULT;
@@ -1033,7 +1039,8 @@ malloc_make_chunks(int bits)
1033static void * 1039static void *
1034malloc_bytes(size_t size) 1040malloc_bytes(size_t size)
1035{ 1041{
1036 int i, j, k; 1042 int i, j;
1043 size_t k;
1037 u_long u, *lp; 1044 u_long u, *lp;
1038 struct pginfo *bp; 1045 struct pginfo *bp;
1039 1046
@@ -1103,7 +1110,7 @@ malloc_bytes(size_t size)
1103 k <<= bp->shift; 1110 k <<= bp->shift;
1104 1111
1105 if (malloc_junk && bp->size != 0) 1112 if (malloc_junk && bp->size != 0)
1106 memset((char *) bp->page + k, SOME_JUNK, bp->size); 1113 memset((char *)bp->page + k, SOME_JUNK, (size_t)bp->size);
1107 1114
1108 return ((u_char *) bp->page + k); 1115 return ((u_char *) bp->page + k);
1109} 1116}
@@ -1160,11 +1167,14 @@ static void *
1160irealloc(void *ptr, size_t size) 1167irealloc(void *ptr, size_t size)
1161{ 1168{
1162 void *p; 1169 void *p;
1163 u_long osize, index, i; 1170 size_t osize;
1171 u_long index, i;
1164 struct pginfo **mp; 1172 struct pginfo **mp;
1165 struct pginfo **pd; 1173 struct pginfo **pd;
1166 struct pdinfo *pi; 1174 struct pdinfo *pi;
1175#ifdef MALLOC_EXTRA_SANITY
1167 u_long pidx; 1176 u_long pidx;
1177#endif /* MALLOC_EXTRA_SANITY */
1168 1178
1169 if (suicide) 1179 if (suicide)
1170 abort(); 1180 abort();
@@ -1193,9 +1203,9 @@ irealloc(void *ptr, size_t size)
1193 wrtwarning("junk pointer, too high to make sense"); 1203 wrtwarning("junk pointer, too high to make sense");
1194 return (NULL); 1204 return (NULL);
1195 } 1205 }
1196 pidx = PI_IDX(index);
1197 pdir_lookup(index, &pi); 1206 pdir_lookup(index, &pi);
1198#ifdef MALLOC_EXTRA_SANITY 1207#ifdef MALLOC_EXTRA_SANITY
1208 pidx = PI_IDX(index);
1199 if (pi == NULL || PD_IDX(pi->dirnum) != pidx) { 1209 if (pi == NULL || PD_IDX(pi->dirnum) != pidx) {
1200 wrterror("(ES): mapped pages not found in directory"); 1210 wrterror("(ES): mapped pages not found in directory");
1201 errno = EFAULT; 1211 errno = EFAULT;
@@ -1293,11 +1303,12 @@ irealloc(void *ptr, size_t size)
1293static __inline__ void 1303static __inline__ void
1294free_pages(void *ptr, u_long index, struct pginfo * info) 1304free_pages(void *ptr, u_long index, struct pginfo * info)
1295{ 1305{
1296 u_long i, l, cachesize = 0, pidx, lidx; 1306 u_long i, pidx, lidx;
1307 size_t l, cachesize = 0;
1297 struct pginfo **pd; 1308 struct pginfo **pd;
1298 struct pdinfo *pi, *spi; 1309 struct pdinfo *pi, *spi;
1299 struct pgfree *pf, *pt = NULL; 1310 struct pgfree *pf, *pt = NULL;
1300 void *tail; 1311 caddr_t tail;
1301 1312
1302 if (info == MALLOC_FREE) { 1313 if (info == MALLOC_FREE) {
1303 wrtwarning("page is already free"); 1314 wrtwarning("page is already free");
@@ -1364,7 +1375,7 @@ free_pages(void *ptr, u_long index, struct pginfo * info)
1364 pd[PI_OFF(index + i)] = MALLOC_FREE; 1375 pd[PI_OFF(index + i)] = MALLOC_FREE;
1365 l += malloc_guard; 1376 l += malloc_guard;
1366 } 1377 }
1367 tail = (char *) ptr + l; 1378 tail = (caddr_t)ptr + l;
1368 1379
1369 if (malloc_hint) 1380 if (malloc_hint)
1370 madvise(ptr, l, MADV_FREE); 1381 madvise(ptr, l, MADV_FREE);
@@ -1394,7 +1405,8 @@ free_pages(void *ptr, u_long index, struct pginfo * info)
1394 1405
1395 /* Race ahead here, while calculating cache size. */ 1406 /* Race ahead here, while calculating cache size. */
1396 for (pf = free_list.next; 1407 for (pf = free_list.next;
1397 pf->page + pf->size < ptr && pf->next != NULL; 1408 (caddr_t)ptr > ((caddr_t)pf->page + pf->size)
1409 && pf->next != NULL;
1398 pf = pf->next) 1410 pf = pf->next)
1399 cachesize += pf->size; 1411 cachesize += pf->size;
1400 1412
@@ -1405,7 +1417,7 @@ free_pages(void *ptr, u_long index, struct pginfo * info)
1405 pt = pt->next; 1417 pt = pt->next;
1406 } 1418 }
1407 1419
1408 if (pf->page > tail) { 1420 if ((caddr_t)pf->page > tail) {
1409 /* Insert before entry */ 1421 /* Insert before entry */
1410 px->next = pf; 1422 px->next = pf;
1411 px->prev = pf->prev; 1423 px->prev = pf->prev;
@@ -1413,12 +1425,12 @@ free_pages(void *ptr, u_long index, struct pginfo * info)
1413 px->prev->next = px; 1425 px->prev->next = px;
1414 pf = px; 1426 pf = px;
1415 px = NULL; 1427 px = NULL;
1416 } else if ((pf->page + pf->size) == ptr) { 1428 } else if (((caddr_t)pf->page + pf->size) == ptr) {
1417 /* Append to the previous entry. */ 1429 /* Append to the previous entry. */
1418 cachesize -= pf->size; 1430 cachesize -= pf->size;
1419 pf->size += l; 1431 pf->size += l;
1420 if (pf->next != NULL && 1432 if (pf->next != NULL &&
1421 pf->page + pf->size == pf->next->page) { 1433 pf->next->page == ((caddr_t)pf->page + pf->size)) {
1422 /* And collapse the next too. */ 1434 /* And collapse the next too. */
1423 pt = pf->next; 1435 pt = pf->next;
1424 pf->size += pt->size; 1436 pf->size += pt->size;
@@ -1461,11 +1473,11 @@ free_pages(void *ptr, u_long index, struct pginfo * info)
1461 if (munmap((char *) pf->page + (malloc_cache - cachesize), 1473 if (munmap((char *) pf->page + (malloc_cache - cachesize),
1462 pf->size - (malloc_cache - cachesize)) != 0) 1474 pf->size - (malloc_cache - cachesize)) != 0)
1463 goto not_return; 1475 goto not_return;
1464 tail = pf->page + pf->size; 1476 tail = (caddr_t)pf->page + pf->size;
1465 lidx = ptr2index(tail) - 1; 1477 lidx = ptr2index(tail) - 1;
1466 pf->size = malloc_cache - cachesize; 1478 pf->size = malloc_cache - cachesize;
1467 1479
1468 index = ptr2index(pf->page + pf->size); 1480 index = ptr2index((caddr_t)pf->page + pf->size);
1469 1481
1470 pidx = PI_IDX(index); 1482 pidx = PI_IDX(index);
1471 if (prev_dir != NULL && PD_IDX(prev_dir->dirnum) >= pidx) 1483 if (prev_dir != NULL && PD_IDX(prev_dir->dirnum) >= pidx)
@@ -1594,13 +1606,15 @@ not_return:
1594 1606
1595/* ARGSUSED */ 1607/* ARGSUSED */
1596static __inline__ void 1608static __inline__ void
1597free_bytes(void *ptr, int index, struct pginfo * info) 1609free_bytes(void *ptr, u_long index, struct pginfo * info)
1598{ 1610{
1599 struct pginfo **mp, **pd; 1611 struct pginfo **mp, **pd;
1600 struct pdinfo *pi; 1612 struct pdinfo *pi;
1613#ifdef MALLOC_EXTRA_SANITY
1601 u_long pidx; 1614 u_long pidx;
1615#endif /* MALLOC_EXTRA_SANITY */
1602 void *vp; 1616 void *vp;
1603 int i; 1617 long i;
1604 1618
1605 /* Find the chunk number on the page */ 1619 /* Find the chunk number on the page */
1606 i = ((u_long) ptr & malloc_pagemask) >> info->shift; 1620 i = ((u_long) ptr & malloc_pagemask) >> info->shift;
@@ -1614,7 +1628,7 @@ free_bytes(void *ptr, int index, struct pginfo * info)
1614 return; 1628 return;
1615 } 1629 }
1616 if (malloc_junk && info->size != 0) 1630 if (malloc_junk && info->size != 0)
1617 memset(ptr, SOME_JUNK, info->size); 1631 memset(ptr, SOME_JUNK, (size_t)info->size);
1618 1632
1619 info->bits[i / MALLOC_BITS] |= 1UL << (i % MALLOC_BITS); 1633 info->bits[i / MALLOC_BITS] |= 1UL << (i % MALLOC_BITS);
1620 info->free++; 1634 info->free++;
@@ -1652,9 +1666,9 @@ free_bytes(void *ptr, int index, struct pginfo * info)
1652 *mp = info->next; 1666 *mp = info->next;
1653 1667
1654 /* Free the page & the info structure if need be */ 1668 /* Free the page & the info structure if need be */
1655 pidx = PI_IDX(ptr2index(info->page));
1656 pdir_lookup(ptr2index(info->page), &pi); 1669 pdir_lookup(ptr2index(info->page), &pi);
1657#ifdef MALLOC_EXTRA_SANITY 1670#ifdef MALLOC_EXTRA_SANITY
1671 pidx = PI_IDX(ptr2index(info->page));
1658 if (pi == NULL || PD_IDX(pi->dirnum) != pidx) { 1672 if (pi == NULL || PD_IDX(pi->dirnum) != pidx) {
1659 wrterror("(ES): mapped pages not found in directory"); 1673 wrterror("(ES): mapped pages not found in directory");
1660 errno = EFAULT; 1674 errno = EFAULT;
@@ -1682,7 +1696,10 @@ static void
1682ifree(void *ptr) 1696ifree(void *ptr)
1683{ 1697{
1684 struct pginfo *info, **pd; 1698 struct pginfo *info, **pd;
1685 u_long pidx, index; 1699 u_long index;
1700#ifdef MALLOC_EXTRA_SANITY
1701 u_long pidx;
1702#endif /* MALLOC_EXTRA_SANITY */
1686 struct pdinfo *pi; 1703 struct pdinfo *pi;
1687 1704
1688 if (!malloc_started) { 1705 if (!malloc_started) {
@@ -1708,9 +1725,9 @@ ifree(void *ptr)
1708 wrtwarning("ifree: junk pointer, too high to make sense"); 1725 wrtwarning("ifree: junk pointer, too high to make sense");
1709 return; 1726 return;
1710 } 1727 }
1711 pidx = PI_IDX(index);
1712 pdir_lookup(index, &pi); 1728 pdir_lookup(index, &pi);
1713#ifdef MALLOC_EXTRA_SANITY 1729#ifdef MALLOC_EXTRA_SANITY
1730 pidx = PI_IDX(index);
1714 if (pi == NULL || PD_IDX(pi->dirnum) != pidx) { 1731 if (pi == NULL || PD_IDX(pi->dirnum) != pidx) {
1715 wrterror("(ES): mapped pages not found in directory"); 1732 wrterror("(ES): mapped pages not found in directory");
1716 errno = EFAULT; 1733 errno = EFAULT;