36 |
|
#endif |
37 |
|
#if (defined(FREEBSD) && !defined(FREEBSD5)) || defined(DFBSD) |
38 |
|
#include <kvm.h> |
39 |
+ |
#include <paths.h> |
40 |
|
#endif |
41 |
|
#if defined(NETBSD) || defined(OPENBSD) |
42 |
|
#include <uvm/uvm_extern.h> |
74 |
|
#endif |
75 |
|
|
76 |
|
#ifdef SOLARIS |
77 |
< |
char *get_svr_from_bsd(char *bsd){ |
77 |
> |
const char *get_svr_from_bsd(const char *bsd){ |
78 |
|
#ifdef HAVE_LIBDEVINFO_H |
79 |
|
mapping_t *map_ptr; |
80 |
|
for(map_ptr = mapping; map_ptr != NULL; map_ptr = map_ptr->next) |
89 |
|
mapping_t *map_ptr; |
90 |
|
mapping_t *map_end_ptr; |
91 |
|
|
91 |
– |
bsd = strdup(bsd); |
92 |
– |
svr = strdup(svr); |
93 |
– |
|
92 |
|
if (mapping == NULL){ |
93 |
|
mapping = malloc(sizeof(mapping_t)); |
94 |
|
if (mapping == NULL) return; |
111 |
|
} |
112 |
|
|
113 |
|
map_ptr->next = NULL; |
114 |
< |
map_ptr->bsd = bsd; |
115 |
< |
map_ptr->svr = svr; |
114 |
> |
map_ptr->bsd = strdup(bsd); |
115 |
> |
map_ptr->svr = strdup(svr); |
116 |
|
|
117 |
|
return; |
118 |
|
} |
213 |
|
int found; |
214 |
|
|
215 |
|
if ((kc = kstat_open()) == NULL) { |
216 |
< |
return; |
216 |
> |
return 1; |
217 |
|
} |
218 |
|
|
219 |
|
for (ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) { |
408 |
|
|
409 |
|
#endif |
410 |
|
|
411 |
+ |
char *update_string(char **dest, const char *src) { |
412 |
+ |
char *new; |
413 |
+ |
|
414 |
+ |
new = realloc(*dest, strlen(src) + 1); |
415 |
+ |
if (new == NULL) { |
416 |
+ |
return NULL; |
417 |
+ |
} |
418 |
+ |
|
419 |
+ |
strcpy(new, src); |
420 |
+ |
*dest = new; |
421 |
+ |
return new; |
422 |
+ |
} |
423 |
+ |
|
424 |
|
long long get_ll_match(char *line, regmatch_t *match){ |
425 |
|
char *ptr; |
426 |
|
long long num; |
461 |
|
int mib[2]; |
462 |
|
size_t size; |
463 |
|
static struct uvmexp *uvm = NULL; |
464 |
+ |
struct uvmexp *new; |
465 |
|
|
466 |
|
mib[0] = CTL_VM; |
467 |
|
mib[1] = VM_UVMEXP; |
470 |
|
return NULL; |
471 |
|
} |
472 |
|
|
473 |
< |
uvm = realloc(uvm, size); |
474 |
< |
if (uvm == NULL) { |
473 |
> |
new = realloc(uvm, size); |
474 |
> |
if (new == NULL) { |
475 |
|
return NULL; |
476 |
|
} |
477 |
+ |
uvm = new; |
478 |
|
|
479 |
|
if (sysctl(mib, 2, uvm, &size, NULL, 0) < 0) { |
480 |
|
return NULL; |