summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortedu <>2003-09-30 00:22:03 +0000
committertedu <>2003-09-30 00:22:03 +0000
commit46d14e519df20470f3dae87cf64e3c915b35b03d (patch)
treecb473ce59e6efe50b2e5d582368c96174fd66167 /src/lib
parentd427f064c56e95cd3c43d5ea3b39f88163b10826 (diff)
downloadopenbsd-46d14e519df20470f3dae87cf64e3c915b35b03d.tar.gz
openbsd-46d14e519df20470f3dae87cf64e3c915b35b03d.tar.bz2
openbsd-46d14e519df20470f3dae87cf64e3c915b35b03d.zip
full stop. reverse course. remove all periods, so as to be aligned
with error messages elsewhere. requested ok deraadt@ henning@
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libc/stdlib/malloc.c80
1 files changed, 40 insertions, 40 deletions
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c
index cde2c9d97a..4e88f1a2a9 100644
--- a/src/lib/libc/stdlib/malloc.c
+++ b/src/lib/libc/stdlib/malloc.c
@@ -8,7 +8,7 @@
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.60 2003/09/27 21:09:15 tedu Exp $"; 11static char rcsid[] = "$OpenBSD: malloc.c,v 1.61 2003/09/30 00:22:03 tedu Exp $";
12#endif /* LIBC_SCCS and not lint */ 12#endif /* LIBC_SCCS and not lint */
13 13
14/* 14/*
@@ -149,7 +149,7 @@ static int fdzero;
149#define MMAP_FD fdzero 149#define MMAP_FD fdzero
150#define INIT_MMAP() \ 150#define INIT_MMAP() \
151 { if ((fdzero=open("/dev/zero", O_RDWR, 0000)) == -1) \ 151 { if ((fdzero=open("/dev/zero", O_RDWR, 0000)) == -1) \
152 wrterror("open of /dev/zero.\n"); } 152 wrterror("open of /dev/zero\n"); }
153#else 153#else
154#define MMAP_FD (-1) 154#define MMAP_FD (-1)
155#define INIT_MMAP() 155#define INIT_MMAP()
@@ -289,7 +289,7 @@ malloc_dump(FILE *fd)
289 fprintf(fd, "Free: @%p [%p...%p[ %ld ->%p <-%p\n", 289 fprintf(fd, "Free: @%p [%p...%p[ %ld ->%p <-%p\n",
290 pf, pf->page, pf->end, pf->size, pf->prev, pf->next); 290 pf, pf->page, pf->end, pf->size, pf->prev, pf->next);
291 if (pf == pf->next) { 291 if (pf == pf->next) {
292 fprintf(fd, "Free_list loops.\n"); 292 fprintf(fd, "Free_list loops\n");
293 break; 293 break;
294 } 294 }
295 } 295 }
@@ -359,7 +359,7 @@ static void
359malloc_exit(void) 359malloc_exit(void)
360{ 360{
361 FILE *fd = fopen("malloc.out", "a"); 361 FILE *fd = fopen("malloc.out", "a");
362 char *q = "malloc() warning: Couldn't dump stats.\n"; 362 char *q = "malloc() warning: Couldn't dump stats\n";
363 if (fd != NULL) { 363 if (fd != NULL) {
364 malloc_dump(fd); 364 malloc_dump(fd);
365 fclose(fd); 365 fclose(fd);
@@ -381,7 +381,7 @@ map_pages(size_t pages)
381 pages <<= malloc_pageshift; 381 pages <<= malloc_pageshift;
382 if (pages > SIZE_T_MAX - (size_t)result) { 382 if (pages > SIZE_T_MAX - (size_t)result) {
383#ifdef MALLOC_EXTRA_SANITY 383#ifdef MALLOC_EXTRA_SANITY
384 wrtwarning("(ES): overflow in map_pages fails.\n"); 384 wrtwarning("(ES): overflow in map_pages fails\n");
385#endif /* MALLOC_EXTRA_SANITY */ 385#endif /* MALLOC_EXTRA_SANITY */
386 errno = ENOMEM; 386 errno = ENOMEM;
387 return (NULL); 387 return (NULL);
@@ -390,7 +390,7 @@ map_pages(size_t pages)
390 390
391 if (brk(tail) == (char *)-1) { 391 if (brk(tail) == (char *)-1) {
392#ifdef MALLOC_EXTRA_SANITY 392#ifdef MALLOC_EXTRA_SANITY
393 wrtwarning("(ES): map_pages fails.\n"); 393 wrtwarning("(ES): map_pages fails\n");
394#endif /* MALLOC_EXTRA_SANITY */ 394#endif /* MALLOC_EXTRA_SANITY */
395 return (NULL); 395 return (NULL);
396 } 396 }
@@ -521,7 +521,7 @@ malloc_init(void)
521 default: 521 default:
522 j = malloc_abort; 522 j = malloc_abort;
523 malloc_abort = 0; 523 malloc_abort = 0;
524 wrtwarning("unknown char in MALLOC_OPTIONS.\n"); 524 wrtwarning("unknown char in MALLOC_OPTIONS\n");
525 malloc_abort = j; 525 malloc_abort = j;
526 break; 526 break;
527 } 527 }
@@ -539,14 +539,14 @@ malloc_init(void)
539 539
540#ifdef MALLOC_STATS 540#ifdef MALLOC_STATS
541 if (malloc_stats && (atexit(malloc_exit) == -1)) 541 if (malloc_stats && (atexit(malloc_exit) == -1))
542 wrtwarning("atexit(2) failed. Will not be able to dump malloc stats on exit.\n"); 542 wrtwarning("atexit(2) failed. Will not be able to dump malloc stats on exit\n");
543#endif /* MALLOC_STATS */ 543#endif /* MALLOC_STATS */
544 544
545 /* Allocate one page for the page directory */ 545 /* Allocate one page for the page directory */
546 page_dir = (struct pginfo **) MMAP(malloc_pagesize); 546 page_dir = (struct pginfo **) MMAP(malloc_pagesize);
547 547
548 if (page_dir == MAP_FAILED) 548 if (page_dir == MAP_FAILED)
549 wrterror("mmap(2) failed, check limits.\n"); 549 wrterror("mmap(2) failed, check limits\n");
550 550
551 /* 551 /*
552 * We need a maximum of malloc_pageshift buckets, steal these from the 552 * We need a maximum of malloc_pageshift buckets, steal these from the
@@ -594,19 +594,19 @@ malloc_pages(size_t size)
594 594
595#ifdef MALLOC_EXTRA_SANITY 595#ifdef MALLOC_EXTRA_SANITY
596 if (pf->size & malloc_pagemask) 596 if (pf->size & malloc_pagemask)
597 wrterror("(ES): junk length entry on free_list.\n"); 597 wrterror("(ES): junk length entry on free_list\n");
598 if (!pf->size) 598 if (!pf->size)
599 wrterror("(ES): zero length entry on free_list.\n"); 599 wrterror("(ES): zero length entry on free_list\n");
600 if (pf->page == pf->end) 600 if (pf->page == pf->end)
601 wrterror("(ES): zero entry on free_list.\n"); 601 wrterror("(ES): zero entry on free_list\n");
602 if (pf->page > pf->end) 602 if (pf->page > pf->end)
603 wrterror("(ES): sick entry on free_list.\n"); 603 wrterror("(ES): sick entry on free_list\n");
604 if ((void*)pf->page >= (void*)sbrk(0)) 604 if ((void*)pf->page >= (void*)sbrk(0))
605 wrterror("(ES): entry on free_list past brk.\n"); 605 wrterror("(ES): entry on free_list past brk\n");
606 if (page_dir[ptr2index(pf->page)] != MALLOC_FREE) 606 if (page_dir[ptr2index(pf->page)] != MALLOC_FREE)
607 wrterror("(ES): non-free first page on free-list.\n"); 607 wrterror("(ES): non-free first page on free-list\n");
608 if (page_dir[ptr2index(pf->end)-1] != MALLOC_FREE) 608 if (page_dir[ptr2index(pf->end)-1] != MALLOC_FREE)
609 wrterror("(ES): non-free last page on free-list.\n"); 609 wrterror("(ES): non-free last page on free-list\n");
610#endif /* MALLOC_EXTRA_SANITY */ 610#endif /* MALLOC_EXTRA_SANITY */
611 611
612 if (pf->size < size) 612 if (pf->size < size)
@@ -629,7 +629,7 @@ malloc_pages(size_t size)
629 629
630#ifdef MALLOC_EXTRA_SANITY 630#ifdef MALLOC_EXTRA_SANITY
631 if (p != NULL && page_dir[ptr2index(p)] != MALLOC_FREE) 631 if (p != NULL && page_dir[ptr2index(p)] != MALLOC_FREE)
632 wrterror("(ES): allocated non-free page on free-list.\n"); 632 wrterror("(ES): allocated non-free page on free-list\n");
633#endif /* MALLOC_EXTRA_SANITY */ 633#endif /* MALLOC_EXTRA_SANITY */
634 634
635 size >>= malloc_pageshift; 635 size >>= malloc_pageshift;
@@ -840,7 +840,7 @@ imalloc(size_t size)
840 result = malloc_pages(size); 840 result = malloc_pages(size);
841 841
842 if (malloc_abort && result == NULL) 842 if (malloc_abort && result == NULL)
843 wrterror("allocation failed.\n"); 843 wrterror("allocation failed\n");
844 844
845 if (malloc_zero && result != NULL) 845 if (malloc_zero && result != NULL)
846 memset(result, 0, size); 846 memset(result, 0, size);
@@ -863,19 +863,19 @@ irealloc(void *ptr, size_t size)
863 abort(); 863 abort();
864 864
865 if (!malloc_started) { 865 if (!malloc_started) {
866 wrtwarning("malloc() has never been called.\n"); 866 wrtwarning("malloc() has never been called\n");
867 return (NULL); 867 return (NULL);
868 } 868 }
869 869
870 index = ptr2index(ptr); 870 index = ptr2index(ptr);
871 871
872 if (index < malloc_pageshift) { 872 if (index < malloc_pageshift) {
873 wrtwarning("junk pointer, too low to make sense.\n"); 873 wrtwarning("junk pointer, too low to make sense\n");
874 return (NULL); 874 return (NULL);
875 } 875 }
876 876
877 if (index > last_index) { 877 if (index > last_index) {
878 wrtwarning("junk pointer, too high to make sense.\n"); 878 wrtwarning("junk pointer, too high to make sense\n");
879 return (NULL); 879 return (NULL);
880 } 880 }
881 881
@@ -885,7 +885,7 @@ irealloc(void *ptr, size_t size)
885 885
886 /* Check the pointer */ 886 /* Check the pointer */
887 if ((u_long)ptr & malloc_pagemask) { 887 if ((u_long)ptr & malloc_pagemask) {
888 wrtwarning("modified (page-) pointer.\n"); 888 wrtwarning("modified (page-) pointer\n");
889 return (NULL); 889 return (NULL);
890 } 890 }
891 891
@@ -905,7 +905,7 @@ irealloc(void *ptr, size_t size)
905 905
906 /* Check the pointer for sane values */ 906 /* Check the pointer for sane values */
907 if ((u_long)ptr & ((1UL<<((*mp)->shift))-1)) { 907 if ((u_long)ptr & ((1UL<<((*mp)->shift))-1)) {
908 wrtwarning("modified (chunk-) pointer.\n"); 908 wrtwarning("modified (chunk-) pointer\n");
909 return (NULL); 909 return (NULL);
910 } 910 }
911 911
@@ -914,7 +914,7 @@ irealloc(void *ptr, size_t size)
914 914
915 /* Verify that it isn't a free chunk already */ 915 /* Verify that it isn't a free chunk already */
916 if ((*mp)->bits[i/MALLOC_BITS] & (1UL<<(i%MALLOC_BITS))) { 916 if ((*mp)->bits[i/MALLOC_BITS] & (1UL<<(i%MALLOC_BITS))) {
917 wrtwarning("chunk is already free.\n"); 917 wrtwarning("chunk is already free\n");
918 return (NULL); 918 return (NULL);
919 } 919 }
920 920
@@ -930,7 +930,7 @@ irealloc(void *ptr, size_t size)
930 } 930 }
931 931
932 } else { 932 } else {
933 wrtwarning("pointer to wrong page.\n"); 933 wrtwarning("pointer to wrong page\n");
934 return (NULL); 934 return (NULL);
935 } 935 }
936 936
@@ -963,17 +963,17 @@ free_pages(void *ptr, int index, struct pginfo *info)
963 void *tail; 963 void *tail;
964 964
965 if (info == MALLOC_FREE) { 965 if (info == MALLOC_FREE) {
966 wrtwarning("page is already free.\n"); 966 wrtwarning("page is already free\n");
967 return; 967 return;
968 } 968 }
969 969
970 if (info != MALLOC_FIRST) { 970 if (info != MALLOC_FIRST) {
971 wrtwarning("pointer to wrong page.\n"); 971 wrtwarning("pointer to wrong page\n");
972 return; 972 return;
973 } 973 }
974 974
975 if ((u_long)ptr & malloc_pagemask) { 975 if ((u_long)ptr & malloc_pagemask) {
976 wrtwarning("modified (page-) pointer.\n"); 976 wrtwarning("modified (page-) pointer\n");
977 return; 977 return;
978 } 978 }
979 979
@@ -1051,7 +1051,7 @@ free_pages(void *ptr, int index, struct pginfo *info)
1051 pf = px; 1051 pf = px;
1052 px = NULL; 1052 px = NULL;
1053 } else { 1053 } else {
1054 wrterror("freelist is destroyed.\n"); 1054 wrterror("freelist is destroyed\n");
1055 } 1055 }
1056 } 1056 }
1057 1057
@@ -1100,12 +1100,12 @@ free_bytes(void *ptr, int index, struct pginfo *info)
1100 i = ((u_long)ptr & malloc_pagemask) >> info->shift; 1100 i = ((u_long)ptr & malloc_pagemask) >> info->shift;
1101 1101
1102 if ((u_long)ptr & ((1UL<<(info->shift))-1)) { 1102 if ((u_long)ptr & ((1UL<<(info->shift))-1)) {
1103 wrtwarning("modified (chunk-) pointer.\n"); 1103 wrtwarning("modified (chunk-) pointer\n");
1104 return; 1104 return;
1105 } 1105 }
1106 1106
1107 if (info->bits[i/MALLOC_BITS] & (1UL<<(i%MALLOC_BITS))) { 1107 if (info->bits[i/MALLOC_BITS] & (1UL<<(i%MALLOC_BITS))) {
1108 wrtwarning("chunk is already free.\n"); 1108 wrtwarning("chunk is already free\n");
1109 return; 1109 return;
1110 } 1110 }
1111 1111
@@ -1140,7 +1140,7 @@ free_bytes(void *ptr, int index, struct pginfo *info)
1140 mp = &((*mp)->next); 1140 mp = &((*mp)->next);
1141#ifdef MALLOC_EXTRA_SANITY 1141#ifdef MALLOC_EXTRA_SANITY
1142 if (!*mp) 1142 if (!*mp)
1143 wrterror("(ES): Not on queue.\n"); 1143 wrterror("(ES): Not on queue\n");
1144#endif /* MALLOC_EXTRA_SANITY */ 1144#endif /* MALLOC_EXTRA_SANITY */
1145 } 1145 }
1146 *mp = info->next; 1146 *mp = info->next;
@@ -1171,7 +1171,7 @@ ifree(void *ptr)
1171 return; 1171 return;
1172 1172
1173 if (!malloc_started) { 1173 if (!malloc_started) {
1174 wrtwarning("malloc() has never been called.\n"); 1174 wrtwarning("malloc() has never been called\n");
1175 return; 1175 return;
1176 } 1176 }
1177 1177
@@ -1182,12 +1182,12 @@ ifree(void *ptr)
1182 index = ptr2index(ptr); 1182 index = ptr2index(ptr);
1183 1183
1184 if (index < malloc_pageshift) { 1184 if (index < malloc_pageshift) {
1185 wrtwarning("junk pointer, too low to make sense.\n"); 1185 wrtwarning("junk pointer, too low to make sense\n");
1186 return; 1186 return;
1187 } 1187 }
1188 1188
1189 if (index > last_index) { 1189 if (index > last_index) {
1190 wrtwarning("junk pointer, too high to make sense.\n"); 1190 wrtwarning("junk pointer, too high to make sense\n");
1191 return; 1191 return;
1192 } 1192 }
1193 1193
@@ -1214,7 +1214,7 @@ malloc(size_t size)
1214 malloc_func = " in malloc():"; 1214 malloc_func = " in malloc():";
1215 _MALLOC_LOCK(); 1215 _MALLOC_LOCK();
1216 if (malloc_active++) { 1216 if (malloc_active++) {
1217 wrtwarning("recursive call.\n"); 1217 wrtwarning("recursive call\n");
1218 malloc_active--; 1218 malloc_active--;
1219 _MALLOC_UNLOCK(); 1219 _MALLOC_UNLOCK();
1220 return (NULL); 1220 return (NULL);
@@ -1224,7 +1224,7 @@ malloc(size_t size)
1224 malloc_active--; 1224 malloc_active--;
1225 _MALLOC_UNLOCK(); 1225 _MALLOC_UNLOCK();
1226 if (malloc_xmalloc && r == NULL) 1226 if (malloc_xmalloc && r == NULL)
1227 wrterror("out of memory.\n"); 1227 wrterror("out of memory\n");
1228 return (r); 1228 return (r);
1229} 1229}
1230 1230
@@ -1234,7 +1234,7 @@ free(void *ptr)
1234 malloc_func = " in free():"; 1234 malloc_func = " in free():";
1235 _MALLOC_LOCK(); 1235 _MALLOC_LOCK();
1236 if (malloc_active++) { 1236 if (malloc_active++) {
1237 wrtwarning("recursive call.\n"); 1237 wrtwarning("recursive call\n");
1238 malloc_active--; 1238 malloc_active--;
1239 _MALLOC_UNLOCK(); 1239 _MALLOC_UNLOCK();
1240 return; 1240 return;
@@ -1254,7 +1254,7 @@ realloc(void *ptr, size_t size)
1254 malloc_func = " in realloc():"; 1254 malloc_func = " in realloc():";
1255 _MALLOC_LOCK(); 1255 _MALLOC_LOCK();
1256 if (malloc_active++) { 1256 if (malloc_active++) {
1257 wrtwarning("recursive call.\n"); 1257 wrtwarning("recursive call\n");
1258 malloc_active--; 1258 malloc_active--;
1259 _MALLOC_UNLOCK(); 1259 _MALLOC_UNLOCK();
1260 return (NULL); 1260 return (NULL);
@@ -1268,6 +1268,6 @@ realloc(void *ptr, size_t size)
1268 malloc_active--; 1268 malloc_active--;
1269 _MALLOC_UNLOCK(); 1269 _MALLOC_UNLOCK();
1270 if (malloc_xmalloc && r == NULL) 1270 if (malloc_xmalloc && r == NULL)
1271 wrterror("out of memory.\n"); 1271 wrterror("out of memory\n");
1272 return (r); 1272 return (r);
1273} 1273}