diff options
| author | deraadt <> | 1999-09-16 19:06:06 +0000 |
|---|---|---|
| committer | deraadt <> | 1999-09-16 19:06:06 +0000 |
| commit | 7888080e5d9ce71af4015e34c3c3a0a0d3d3119a (patch) | |
| tree | bd72929fd74cca0944230ad65aa8f6b821c9f7f0 /src/lib/libc/stdlib/malloc.c | |
| parent | f8087e2671bd27448a73944c96b9dfb2132a0ee2 (diff) | |
| download | openbsd-7888080e5d9ce71af4015e34c3c3a0a0d3d3119a.tar.gz openbsd-7888080e5d9ce71af4015e34c3c3a0a0d3d3119a.tar.bz2 openbsd-7888080e5d9ce71af4015e34c3c3a0a0d3d3119a.zip | |
use writev() where possible
Diffstat (limited to 'src/lib/libc/stdlib/malloc.c')
| -rw-r--r-- | src/lib/libc/stdlib/malloc.c | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c index e75c7cdb09..8b90bb5d57 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) |
| 11 | static char rcsid[] = "$OpenBSD: malloc.c,v 1.35 1999/02/03 03:58:05 d Exp $"; | 11 | static char rcsid[] = "$OpenBSD: malloc.c,v 1.36 1999/09/16 19:06:06 deraadt Exp $"; |
| 12 | #endif /* LIBC_SCCS and not lint */ | 12 | #endif /* LIBC_SCCS and not lint */ |
| 13 | 13 | ||
| 14 | /* | 14 | /* |
| @@ -37,15 +37,16 @@ static char rcsid[] = "$OpenBSD: malloc.c,v 1.35 1999/02/03 03:58:05 d Exp $"; | |||
| 37 | */ | 37 | */ |
| 38 | #define SOME_JUNK 0xd0 /* as in "Duh" :-) */ | 38 | #define SOME_JUNK 0xd0 /* as in "Duh" :-) */ |
| 39 | 39 | ||
| 40 | #include <sys/types.h> | ||
| 41 | #include <sys/param.h> | ||
| 42 | #include <sys/mman.h> | ||
| 43 | #include <sys/uio.h> | ||
| 40 | #include <stdio.h> | 44 | #include <stdio.h> |
| 41 | #include <stdlib.h> | 45 | #include <stdlib.h> |
| 42 | #include <string.h> | 46 | #include <string.h> |
| 43 | #include <unistd.h> | 47 | #include <unistd.h> |
| 44 | #include <fcntl.h> | 48 | #include <fcntl.h> |
| 45 | #include <errno.h> | 49 | #include <errno.h> |
| 46 | #include <sys/types.h> | ||
| 47 | #include <sys/param.h> | ||
| 48 | #include <sys/mman.h> | ||
| 49 | 50 | ||
| 50 | /* | 51 | /* |
| 51 | * The basic parameters you can tweak. | 52 | * The basic parameters you can tweak. |
| @@ -363,10 +364,18 @@ wrterror(p) | |||
| 363 | char *p; | 364 | char *p; |
| 364 | { | 365 | { |
| 365 | char *q = " error: "; | 366 | char *q = " error: "; |
| 366 | write(2, __progname, strlen(__progname)); | 367 | struct iovec iov[4]; |
| 367 | write(2, malloc_func, strlen(malloc_func)); | 368 | |
| 368 | write(2, q, strlen(q)); | 369 | iov[0].iov_base = __progname; |
| 369 | write(2, p, strlen(p)); | 370 | iov[0].iov_len = strlen(__progname); |
| 371 | iov[1].iov_base = malloc_func; | ||
| 372 | iov[1].iov_len = strlen(malloc_func); | ||
| 373 | iov[2].iov_base = q; | ||
| 374 | iov[2].iov_len = strlen(q); | ||
| 375 | iov[3].iov_base = p; | ||
| 376 | iov[3].iov_len = strlen(p); | ||
| 377 | writev(STDERR_FILENO, iov, 4); | ||
| 378 | |||
| 370 | suicide = 1; | 379 | suicide = 1; |
| 371 | #ifdef MALLOC_STATS | 380 | #ifdef MALLOC_STATS |
| 372 | if (malloc_stats) | 381 | if (malloc_stats) |
| @@ -380,14 +389,22 @@ wrtwarning(p) | |||
| 380 | char *p; | 389 | char *p; |
| 381 | { | 390 | { |
| 382 | char *q = " warning: "; | 391 | char *q = " warning: "; |
| 392 | struct iovec iov[4]; | ||
| 393 | |||
| 383 | if (malloc_abort) | 394 | if (malloc_abort) |
| 384 | wrterror(p); | 395 | wrterror(p); |
| 385 | else if (malloc_silent) | 396 | else if (malloc_silent) |
| 386 | return; | 397 | return; |
| 387 | write(2, __progname, strlen(__progname)); | 398 | |
| 388 | write(2, malloc_func, strlen(malloc_func)); | 399 | iov[0].iov_base = __progname; |
| 389 | write(2, q, strlen(q)); | 400 | iov[0].iov_len = strlen(__progname); |
| 390 | write(2, p, strlen(p)); | 401 | iov[1].iov_base = malloc_func; |
| 402 | iov[1].iov_len = strlen(malloc_func); | ||
| 403 | iov[2].iov_base = q; | ||
| 404 | iov[2].iov_len = strlen(q); | ||
| 405 | iov[3].iov_base = p; | ||
| 406 | iov[3].iov_len = strlen(p); | ||
| 407 | writev(STDERR_FILENO, iov, 4); | ||
| 391 | } | 408 | } |
| 392 | 409 | ||
| 393 | #ifdef MALLOC_STATS | 410 | #ifdef MALLOC_STATS |
