Ignore:
Timestamp:
Dec 9, 2014 10:32:28 PM (7 years ago)
Author:
ldelgass
Message:

Preallocate full size Rappture buffer for data payloads

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nanovis/branches/1.1/FlowCmd.cpp

    r4613 r4830  
    231231        return TCL_ERROR;
    232232    }
    233     Rappture::Buffer buf;
     233    Rappture::Buffer buf(nBytes);
    234234    TRACE("Flow data loading bytes: %d components: %d", nBytes, nComponents);
    235235    if (GetDataStream(interp, buf, nBytes) != TCL_OK) {
    236236        return TCL_ERROR;
    237237    }
     238    char *bytes = (char *)buf.bytes();
     239    size_t length = buf.size();
     240
    238241    Rappture::Unirect3d *dataPtr;
    239242    dataPtr = new Rappture::Unirect3d(nComponents);
    240243
    241244    Flow *flow = (Flow *)clientData;
    242     size_t length = buf.size();
    243     char *bytes = (char *)buf.bytes();
    244245    if ((length > 4) && (strncmp(bytes, "<DX>", 4) == 0)) {
    245246        if (!dataPtr->importDx(result, nComponents, length - 4, bytes + 4)) {
     
    292293    {
    293294        char info[1024];
    294         ssize_t nWritten;
    295         size_t length;
    296 
    297         length = sprintf(info, "nv>data tag %s min %g max %g\n",
    298                          flow->name(), dataPtr->magMin(), dataPtr->magMax());
    299         nWritten  = write(1, info, length);
    300         assert(nWritten == (ssize_t)strlen(info));
     295        int length =
     296            sprintf(info, "nv>data tag %s min %g max %g\n",
     297                    flow->name(), dataPtr->magMin(), dataPtr->magMax());
     298        ssize_t nWritten = write(1, info, (size_t)length);
     299        if (nWritten != (ssize_t)length) {
     300            ERROR("Short write");
     301            return TCL_ERROR;
     302        }
    301303    }
    302304    NanoVis::eventuallyRedraw(NanoVis::MAP_FLOWS);
Note: See TracChangeset for help on using the changeset viewer.