ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/tools.c
(Generate patch)

Comparing projects/libstatgrab/src/libstatgrab/tools.c (file contents):
Revision 1.34 by tdb, Sun Apr 4 22:09:32 2004 UTC vs.
Revision 1.37 by ats, Sun Apr 4 23:55:48 2004 UTC

# Line 36 | Line 36
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>
# Line 410 | Line 411 | size_t strlcat(char *dst, const char *src, size_t siz)
411  
412   #endif
413  
414 + char *update_string(char **dest, const char *src) {
415 +        char *new;
416 +
417 +        new = realloc(*dest, strlen(src) + 1);
418 +        if (new == NULL) {
419 +                return NULL;
420 +        }
421 +
422 +        strcpy(new, src);
423 +        *dest = new;
424 +        return new;
425 + }
426 +
427   long long get_ll_match(char *line, regmatch_t *match){
428          char *ptr;
429          long long num;
# Line 450 | Line 464 | struct uvmexp *get_uvmexp() {
464          int mib[2];
465          size_t size;
466          static struct uvmexp *uvm = NULL;
467 +        struct uvmexp *new;
468  
469          mib[0] = CTL_VM;
470          mib[1] = VM_UVMEXP;
# Line 458 | Line 473 | struct uvmexp *get_uvmexp() {
473                  return NULL;
474          }
475  
476 <        uvm = realloc(uvm, size);
477 <        if (uvm == NULL) {
476 >        new = realloc(uvm, size);
477 >        if (new == NULL) {
478                  return NULL;
479          }
480 +        uvm = new;
481  
482          if (sysctl(mib, 2, uvm, &size, NULL, 0) < 0) {
483                  return NULL;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines