From abe1bc9e98b3ba006b46e1eecf15fb39a1625c64 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Mon, 22 Jan 2001 23:00:13 +0000 Subject: [PATCH] fixed borland warning --- src/ca/Makefile | 1 + src/ca/comBuf.cpp | 34 ++++++++++++++++++++++++++++++++++ src/ca/comBuf_IL.h | 16 ---------------- src/ca/comQueSend_IL.h | 19 ++++++++++++++----- src/ca/iocinf.h | 2 +- src/ca/syncgrp.cpp | 5 ++--- 6 files changed, 52 insertions(+), 25 deletions(-) create mode 100644 src/ca/comBuf.cpp diff --git a/src/ca/Makefile b/src/ca/Makefile index 0c05cc10c..20941b2fc 100644 --- a/src/ca/Makefile +++ b/src/ca/Makefile @@ -50,6 +50,7 @@ LIBSRCS += syncGroupNotify.cpp LIBSRCS += localHostName.cpp LIBSRCS += comQueRecv.cpp LIBSRCS += comQueSend.cpp +LIBSRCS += comBuf.cpp LIBSRCS += tcpiiuPrivateListOfIO.cpp LIBSRCS += hostNameCache.cpp LIBSRCS += ioCounter.cpp diff --git a/src/ca/comBuf.cpp b/src/ca/comBuf.cpp new file mode 100644 index 000000000..9dd2655e0 --- /dev/null +++ b/src/ca/comBuf.cpp @@ -0,0 +1,34 @@ + +/* + * $Id$ + * + * + * L O S A L A M O S + * Los Alamos National Laboratory + * Los Alamos, New Mexico 87545 + * + * Copyright, 1986, The Regents of the University of California. + * + * + * Author Jeffrey O. Hill + * johill@lanl.gov + */ + +#include "iocinf.h" +#include "comBuf_IL.h" + +bool comBuf::flushToWire ( wireSendAdapter &wire ) +{ + unsigned occupied = this->occupiedBytes (); + while ( occupied ) { + unsigned nBytes = wire.sendBytes ( &this->buf[this->nextReadIndex], + occupied ); + if ( nBytes == 0u ) { + this->nextReadIndex = this->nextWriteIndex; + return false; + } + this->nextReadIndex += nBytes; + occupied = this->occupiedBytes (); + } + return true; +} \ No newline at end of file diff --git a/src/ca/comBuf_IL.h b/src/ca/comBuf_IL.h index f41d4260a..299bd0934 100644 --- a/src/ca/comBuf_IL.h +++ b/src/ca/comBuf_IL.h @@ -131,22 +131,6 @@ inline void comBuf::compress () } } -inline bool comBuf::flushToWire ( wireSendAdapter &wire ) -{ - unsigned occupied = this->occupiedBytes (); - while ( occupied ) { - unsigned nBytes = wire.sendBytes ( &this->buf[this->nextReadIndex], - occupied ); - if ( nBytes == 0u ) { - this->nextReadIndex = this->nextWriteIndex; - return false; - } - this->nextReadIndex += nBytes; - occupied = this->occupiedBytes (); - } - return true; -} - inline unsigned comBuf::fillFromWire ( wireRecvAdapter &wire ) { unsigned nNewBytes = wire.recvBytes ( &this->buf[this->nextWriteIndex], diff --git a/src/ca/comQueSend_IL.h b/src/ca/comQueSend_IL.h index 045a94fe5..7d4c89d4b 100644 --- a/src/ca/comQueSend_IL.h +++ b/src/ca/comQueSend_IL.h @@ -82,20 +82,29 @@ inline void comQueSend_copyIn ( unsigned &nBytesPending, tsDLList < comBuf > &comBufList, bufferReservoir &reservoir, const T *pVal, unsigned nElem ) { - unsigned nCopied; - nBytesPending += sizeof ( T ) * nElem; comBuf *pComBuf = comBufList.last (); if ( pComBuf ) { - nCopied = pComBuf->copyIn ( pVal, nElem ); + unsigned nCopied = pComBuf->copyIn ( pVal, nElem ); + if ( nElem > nCopied ) { + comQueSend_copyInWithReservour ( comBufList, reservoir, &pVal[nCopied], + nElem - nCopied ); + } } else { - nCopied = 0u; + comQueSend_copyInWithReservour ( comBufList, reservoir, pVal, nElem ); } +} +template < class T > +void comQueSend_copyInWithReservour ( + tsDLList < comBuf > &comBufList, bufferReservoir &reservoir, + const T *pVal, unsigned nElem ) +{ + unsigned nCopied = 0u; while ( nElem > nCopied ) { - pComBuf = reservoir.fetchOneBuffer (); + comBuf *pComBuf = reservoir.fetchOneBuffer (); // // This fails only if space was not preallocated. // See comments at the top of this program on diff --git a/src/ca/iocinf.h b/src/ca/iocinf.h index ebfc8f135..793e499b7 100644 --- a/src/ca/iocinf.h +++ b/src/ca/iocinf.h @@ -893,7 +893,7 @@ private: double averagePeriod; static tsFreeList < class bhe, 1024 > freeList; - ~bhe (); // force allocation from freeList + epicsShareFunc ~bhe (); // force allocation from freeList }; class caErrorCode { diff --git a/src/ca/syncgrp.cpp b/src/ca/syncgrp.cpp index 7f07cdcd8..91e5f3fc8 100644 --- a/src/ca/syncgrp.cpp +++ b/src/ca/syncgrp.cpp @@ -135,9 +135,8 @@ int epicsShareAPI ca_sg_stat ( const CA_SYNC_GID gid ) { CASG *pcasg; cac *pcac; - int caStatus; - caStatus = fetchClientContext (&pcac); + int caStatus = fetchClientContext (&pcac); if ( caStatus != ECA_NORMAL ) { return caStatus; } @@ -145,7 +144,7 @@ int epicsShareAPI ca_sg_stat ( const CA_SYNC_GID gid ) pcasg = pcac->lookupCASG ( gid ); if ( ! pcasg ) { printf("Bad Sync Group Id\n"); - caStatus = ECA_BADSYNCGRP; + return ECA_BADSYNCGRP; } pcasg->show (1000u);