diff options
| author | otto <> | 2008-11-12 09:41:49 +0000 |
|---|---|---|
| committer | otto <> | 2008-11-12 09:41:49 +0000 |
| commit | 66d33d044b2d95d50bc554a899d8ff7a0ec2eaca (patch) | |
| tree | ff7093069efee31faf443efb290be528473abca4 /src/lib/libc/stdlib | |
| parent | 364cbab96ffd1db4271cef83317f82738999d996 (diff) | |
| download | openbsd-66d33d044b2d95d50bc554a899d8ff7a0ec2eaca.tar.gz openbsd-66d33d044b2d95d50bc554a899d8ff7a0ec2eaca.tar.bz2 openbsd-66d33d044b2d95d50bc554a899d8ff7a0ec2eaca.zip | |
avoid a few strlen calls for constant strings; prompted by tg; ok djm@
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libc/stdlib/malloc.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c index 37404a199e..f5f0ab730f 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.106 2008/11/06 12:32:45 otto Exp $ */ | 1 | /* $OpenBSD: malloc.c,v 1.107 2008/11/12 09:41:49 otto Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2008 Otto Moerbeek <otto@drijf.net> | 3 | * Copyright (c) 2008 Otto Moerbeek <otto@drijf.net> |
| 4 | * | 4 | * |
| @@ -312,7 +312,7 @@ malloc_dump(int fd) | |||
| 312 | static void | 312 | static void |
| 313 | malloc_exit(void) | 313 | malloc_exit(void) |
| 314 | { | 314 | { |
| 315 | char *q = "malloc() warning: Couldn't dump stats\n"; | 315 | const char q[] = "malloc() warning: Couldn't dump stats\n"; |
| 316 | int save_errno = errno, fd; | 316 | int save_errno = errno, fd; |
| 317 | 317 | ||
| 318 | fd = open("malloc.out", O_RDWR|O_APPEND); | 318 | fd = open("malloc.out", O_RDWR|O_APPEND); |
| @@ -320,7 +320,7 @@ malloc_exit(void) | |||
| 320 | malloc_dump(fd); | 320 | malloc_dump(fd); |
| 321 | close(fd); | 321 | close(fd); |
| 322 | } else | 322 | } else |
| 323 | write(STDERR_FILENO, q, strlen(q)); | 323 | write(STDERR_FILENO, q, sizeof(q) - 1); |
| 324 | errno = save_errno; | 324 | errno = save_errno; |
| 325 | } | 325 | } |
| 326 | #endif /* MALLOC_STATS */ | 326 | #endif /* MALLOC_STATS */ |
| @@ -630,13 +630,13 @@ omalloc_init(struct dir_info *d) | |||
| 630 | case 'Z': | 630 | case 'Z': |
| 631 | malloc_zero = 1; | 631 | malloc_zero = 1; |
| 632 | break; | 632 | break; |
| 633 | default: | 633 | default: { |
| 634 | j = malloc_abort; | 634 | const char q[] = "malloc() warning: " |
| 635 | malloc_abort = 0; | 635 | "unknown char in MALLOC_OPTIONS\n"; |
| 636 | wrterror("unknown char in MALLOC_OPTIONS"); | 636 | write(STDERR_FILENO, q, sizeof(q) - 1); |
| 637 | malloc_abort = j; | ||
| 638 | break; | 637 | break; |
| 639 | } | 638 | } |
| 639 | } | ||
| 640 | } | 640 | } |
| 641 | } | 641 | } |
| 642 | 642 | ||
| @@ -649,9 +649,9 @@ omalloc_init(struct dir_info *d) | |||
| 649 | 649 | ||
| 650 | #ifdef MALLOC_STATS | 650 | #ifdef MALLOC_STATS |
| 651 | if (malloc_stats && (atexit(malloc_exit) == -1)) { | 651 | if (malloc_stats && (atexit(malloc_exit) == -1)) { |
| 652 | char *q = "malloc() warning: atexit(2) failed." | 652 | const char q[] = "malloc() warning: atexit(2) failed." |
| 653 | " Will not be able to dump stats on exit\n"; | 653 | " Will not be able to dump stats on exit\n"; |
| 654 | write(STDERR_FILENO, q, strlen(q)); | 654 | write(STDERR_FILENO, q, sizeof(q) - 1); |
| 655 | } | 655 | } |
| 656 | #endif /* MALLOC_STATS */ | 656 | #endif /* MALLOC_STATS */ |
| 657 | 657 | ||
