IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 24999


Ignore:
Timestamp:
Aug 4, 2009, 2:50:13 PM (17 years ago)
Author:
jhoblitt
Message:

yet more memory mangling fun

Location:
trunk/Nebulous/nebclient
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous/nebclient/src/nebclient.c

    r24997 r24999  
    812812    }
    813813
    814     nullstrncpy(stat->so_id, resultArray[0], 256);
    815     nullstrncpy(stat->ext_id, resultArray[1], 256);
    816     nullstrncpy(stat->read_lock, resultArray[2], 256);
     814    stat->so_id     = atol(resultArray[0]);
     815    stat->ext_id    = atol(resultArray[1]);
     816    stat->read_lock = atoi(resultArray[2]);
    817817    nullstrncpy(stat->write_lock, resultArray[3], 256);
    818818    nullstrncpy(stat->epoch, resultArray[4], 256);
     
    831831    }
    832832
    833     xfree(stat->so_id);
    834     xfree(stat->ext_id);
    835     xfree(stat->read_lock);
    836     xfree(stat->write_lock);
    837     xfree(stat->epoch);
    838     xfree(stat->mtime);
    839     xfree(stat);
     833    nebFree(stat);
    840834}
    841835
     
    935929            return -1;
    936930        }
     931
     932        int available = stat->available;
     933        nebObjectStatFree(stat);
     934
    937935        // start at one so cull() is called one less time then the # of
    938936        // instances
    939         for (long i = 1; i < stat->available; i++) {
     937        for (long i = 1; i < available; i++) {
    940938            if (!nebCull(server, key)) {
    941                 nebObjectStatFree(stat);
    942939                return -1;
    943940            }
    944941            removed++;
    945942        }
    946         nebObjectStatFree(stat);
    947943    }
    948944
     
    958954
    959955void nebFree(void *ptr) {
     956    if (!ptr) { return; }
    960957    xfree(ptr);
    961958}
     
    11971194    }
    11981195
     1196    if (!dest) {
     1197        dest = xmalloc(n + 1);
     1198    }
     1199
    11991200    return strncpy(dest, src, n);
    12001201}
  • trunk/Nebulous/nebclient/src/nebclient.h

    r24939 r24999  
    3838
    3939typedef struct {
    40     char            so_id[256];         ///< storage object ID
    41     char            ext_id[256];        ///< storage object key (name)
    42     char            read_lock[256];     ///< read lock value
     40    long            so_id;              ///< storage object ID
     41    long            ext_id;             ///< storage object key (name)
     42    int             read_lock;          ///< read lock value
    4343    char            write_lock[256];    ///< write lock value
    4444    char            epoch[256];         ///< creation time stamp
  • trunk/Nebulous/nebclient/tests/tests.c

    r24939 r24999  
    9898
    9999    char *copies = nebGetXattr(server, key, "user.copies");
    100     neb_ok(server, strcmp(copies, "2") == 0, "get user.copies xattr");
     100    neb_ok(server, copies != NULL && strcmp(copies, "2") == 0, "get user.copies xattr");
    101101    char **xattrs = NULL;
    102102    int n_xattrs = nebListXattr(server, key, &xattrs);
    103     printf("# %s\n\n", xattrs[0]);
    104     neb_ok(server, n_xattrs == 1, "count of xattrs");
    105     neb_ok(server, strcmp(xattrs[0], "user.copies") == 0, "user.copies xattr exists");
     103    neb_ok(server, xattrs != NULL && n_xattrs == 1, "count of xattrs");
     104    neb_ok(server, xattrs != NULL && strcmp(xattrs[0], "user.copies") == 0, "user.copies xattr exists");
    106105    neb_ok(server, nebRemoveXattr(server, key, "user.copies"), "remove user.copies xattr");
    107106
Note: See TracChangeset for help on using the changeset viewer.