Deleted Added
full compact
memstat_malloc.c (147997) memstat_malloc.c (148038)
1/*-
2 * Copyright (c) 2005 Robert N. M. Watson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 2005 Robert N. M. Watson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/lib/libmemstat/memstat_malloc.c 147997 2005-07-14 17:40:02Z rwatson $
26 * $FreeBSD: head/lib/libmemstat/memstat_malloc.c 148038 2005-07-15 10:13:50Z rwatson $
27 */
28
29#include <sys/param.h>
30#include <sys/malloc.h>
31#include <sys/sysctl.h>
32
33#include <err.h>
34#include <errno.h>

--- 40 unchanged lines hidden (view full) ---

75 size = sizeof(maxcpus);
76 if (sysctlbyname("kern.smp.maxcpus", &maxcpus, &size, NULL, 0) < 0) {
77 error = errno;
78 perror("kern.smp.maxcpus");
79 errno = error;
80 return (-1);
81 }
82 if (size != sizeof(maxcpus)) {
27 */
28
29#include <sys/param.h>
30#include <sys/malloc.h>
31#include <sys/sysctl.h>
32
33#include <err.h>
34#include <errno.h>

--- 40 unchanged lines hidden (view full) ---

75 size = sizeof(maxcpus);
76 if (sysctlbyname("kern.smp.maxcpus", &maxcpus, &size, NULL, 0) < 0) {
77 error = errno;
78 perror("kern.smp.maxcpus");
79 errno = error;
80 return (-1);
81 }
82 if (size != sizeof(maxcpus)) {
83 fprintf(stderr, "kern.smp.maxcpus: wronge size");
83 fprintf(stderr, "kern.smp.maxcpus: wrong size");
84 errno = EINVAL;
85 return (-1);
86 }
87
88 if (maxcpus > MEMSTAT_MAXCPU) {
89 fprintf(stderr, "kern.smp.maxcpus: too many CPUs\n");
90 errno = EINVAL;
91 return (-1);
92 }
93
94 size = sizeof(count);
95 if (sysctlbyname("kern.malloc_count", &count, &size, NULL, 0) < 0) {
96 error = errno;
97 perror("kern.malloc_count");
98 errno = error;
99 return (-1);
100 }
101 if (size != sizeof(count)) {
84 errno = EINVAL;
85 return (-1);
86 }
87
88 if (maxcpus > MEMSTAT_MAXCPU) {
89 fprintf(stderr, "kern.smp.maxcpus: too many CPUs\n");
90 errno = EINVAL;
91 return (-1);
92 }
93
94 size = sizeof(count);
95 if (sysctlbyname("kern.malloc_count", &count, &size, NULL, 0) < 0) {
96 error = errno;
97 perror("kern.malloc_count");
98 errno = error;
99 return (-1);
100 }
101 if (size != sizeof(count)) {
102 fprintf(stderr, "kern.malloc_count: wronge size");
102 fprintf(stderr, "kern.malloc_count: wrong size");
103 errno = EINVAL;
104 return (-1);
105 }
106
107 size = sizeof(*mthp) + count * (sizeof(*mthp) + sizeof(*mtsp) *
108 maxcpus);
109
110 buffer = malloc(size);

--- 130 unchanged lines hidden ---
103 errno = EINVAL;
104 return (-1);
105 }
106
107 size = sizeof(*mthp) + count * (sizeof(*mthp) + sizeof(*mtsp) *
108 maxcpus);
109
110 buffer = malloc(size);

--- 130 unchanged lines hidden ---